Skip to content

Commit b981ca9

Browse files
committed
fix help hint showing shadowed option name
when a subcommand option shadows a help option name (e.g. -h), the error hint was still suggesting the shadowed name. now it uses get_help_option_names() which filters out names claimed by other options, so it picks a working alternative like --help.
1 parent cdab890 commit b981ca9

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

src/click/exceptions.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,9 @@ def show(self, file: t.IO[t.Any] | None = None) -> None:
7878
self.ctx is not None
7979
and self.ctx.command.get_help_option(self.ctx) is not None
8080
):
81+
help_names = self.ctx.command.get_help_option_names(self.ctx)
8182
hint = _("Try '{command} {option}' for help.").format(
82-
command=self.ctx.command_path, option=self.ctx.help_option_names[0]
83+
command=self.ctx.command_path, option=help_names[0]
8384
)
8485
hint = f"{hint}\n"
8586
if self.ctx is not None:

0 commit comments

Comments
 (0)