Skip to content
Myr

Merge pull request #860 from guildai/master

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Pass ctx to NoSuchOption exceptions

authored by David Lord · committed by GitHub · parents 2c622ee, fa389c1 · Browse files · 2 files+4 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+4 added−2 removed

  • other:+4 added−2 removed

2 files+4 added−2 removed

modified:click/parser.py+2 added-2 removed
319 unmodified lines
320 def _match_long_opt(self, opt, explicit_value, state):321 if opt not in self._long_opt:322 possibilities = [word for word in self._long_opt323 if word.startswith(opt)]324 raise NoSuchOption(opt, possibilities=possibilities)324 raise NoSuchOption(opt, possibilities=possibilities, ctx=self.ctx)325326 option = self._long_opt[opt]327 if option.takes_value:328 # At this point it's safe to modify rargs by injecting the
34 unmodified lines
363 if not option:364 if self.ignore_unknown_options:365 unknown_options.append(ch)366 continue367 raise NoSuchOption(opt)367 raise NoSuchOption(opt, ctx=self.ctx)368 if option.takes_value:369 # Any characters left in arg? Pretend they're the370 # next arg, and stop consuming characters of arg.371 if i < len(arg):
55 unmodified lines
modified:CHANGES.rst+2 added
49 unmodified lines
50- Add test and documentation for ``Option`` naming: functionality. (`#799`_)51- Update doc to match arg name for ``path_type``. (`#801`_)52- Raw strings added so correct escaping occurs. (`#807`_)53- Add bool conversion for "t" and "f". (`#842`_)54- ``NoSuchOption`` errors take ``ctx`` so that ``--help`` hint gets printed in error output. (`#860`_)55- Fixed the behavior of Click error messages with regards to unicode on 2.x and 3.x. Message is now always unicode and the str and unicode special methods work as you expect on that platform. (`#862`_)56- Progress bar now uses stderr by default. (`#863`_)57- Add support for auto-completion documentation. (`#866`_, `#869`_)58- Allow ``CliRunner`` to separate stdout and stderr. (`#868`_)
83 unmodified lines
142.. _#806: https://github.com/pallets/click/pull/806143.. _#807: https://github.com/pallets/click/pull/807144.. _#809: https://github.com/pallets/click/pull/809145.. _#842: https://github.com/pallets/click/pull/842146.. _#860: https://github.com/pallets/click/issues/860147.. _#862: https://github.com/pallets/click/issues/862148.. _#863: https://github.com/pallets/click/pull/863149.. _#865: https://github.com/pallets/click/pull/865150.. _#866: https://github.com/pallets/click/issues/866
402 unmodified lines