Skip to content

Commit

Permalink
Merge pull request #1870 from AdrienPensart/allow_colors_in_metavar
Browse files Browse the repository at this point in the history
repr is erasing ANSI escapes codes
  • Loading branch information
davidism committed May 11, 2021
2 parents 482e6e6 + e3e1691 commit 5215fc1
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/click/core.py
Expand Up @@ -2372,7 +2372,7 @@ def get_error_hint(self, ctx: Context) -> str:
indicate which param caused the error.
"""
hint_list = self.opts or [self.human_readable_name]
return " / ".join(repr(x) for x in hint_list)
return " / ".join(f"'{x}'" for x in hint_list)

def shell_complete(self, ctx: Context, incomplete: str) -> t.List["CompletionItem"]:
"""Return a list of completions for the incomplete value. If a
Expand Down Expand Up @@ -2926,7 +2926,7 @@ def get_usage_pieces(self, ctx: Context) -> t.List[str]:
return [self.make_metavar()]

def get_error_hint(self, ctx: Context) -> str:
return repr(self.make_metavar())
return f"'{self.make_metavar()}'"

def add_to_parser(self, parser: OptionParser, ctx: Context) -> None:
parser.add_argument(dest=self.name, nargs=self.nargs, obj=self)

0 comments on commit 5215fc1

Please sign in to comment.