(self, file: t.IO[t.Any] | None = None)
| 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 | |
| 114 | class BadParameter(UsageError): |
no test coverage detected