MCPcopy
hub / github.com/pallets/click / show

Method show

src/click/exceptions.py:87–111  ·  view source on GitHub ↗
(self, file: t.IO[t.Any] | None = None)

Source from the content-addressed store, hash-verified

85 self.cmd = self.ctx.command if self.ctx else None
86
87 def show(self, file: t.IO[t.Any] | None = None) -> None:
88 if file is None:
89 file = get_text_stderr()
90 color = None
91 hint = ""
92 if (
93 self.ctx is not None
94 and self.ctx.command.get_help_option(self.ctx) is not None
95 ):
96 help_names = self.ctx.command.get_help_option_names(self.ctx)
97 # Pick the longest name (like ``--help`` over ``-h``) for
98 # readability in error messages.
99 hint = _("Try '{command} {option}' for help.").format(
100 command=self.ctx.command_path,
101 option=max(help_names, key=len),
102 )
103 hint = f"{hint}\n"
104 if self.ctx is not None:
105 color = self.ctx.color
106 echo(f"{self.ctx.get_usage()}\n{hint}", file=file, color=color)
107 echo(
108 _("Error: {message}").format(message=self.format_message()),
109 file=file,
110 color=color,
111 )
112
113
114class BadParameter(UsageError):

Callers 2

mainMethod · 0.45
display_cmdFunction · 0.45

Calls 6

get_text_stderrFunction · 0.85
get_help_optionMethod · 0.80
get_help_option_namesMethod · 0.80
echoFunction · 0.70
get_usageMethod · 0.45
format_messageMethod · 0.45

Tested by

no test coverage detected