Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/click/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,6 +402,17 @@ def _match_short_opt(self, arg: str, state: _ParsingState) -> None:
if self.ignore_unknown_options:
unknown_options.append(ch)
continue
# If the very first character of the short-option group is
# not a registered option, the user most likely intended the
# entire token as a single option name (e.g. -dbgwrong).
# Raise with the full original argument so the error message
# is more helpful. If a later character fails, we keep the
# per-character diagnostic (e.g. -abZ where -a and -b are
# valid but -Z is not).
if i == 2:
raise NoSuchOption(
arg, possibilities=self._long_opt, ctx=self.ctx
)
raise NoSuchOption(opt, ctx=self.ctx)
if option.takes_value:
# Any characters left in arg? Pretend they're the
Expand Down
Loading