Merge branch '2.x-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Armin Ronacher · committed by Armin Ronacher · parents a85c5b7, dd41abf · Browse files · 2 files·+31 added−6 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+31 added−6 removed
- other:+31 added−6 removed
Provenance
- Commit
81b2d3e- Tree
a41900c- Author
Armin Ronacher <armin.ronacher@active-4.com>- Committer
Armin Ronacher <armin.ronacher@active-4.com>- Parent 1
a85c5b7- Parent 2
dd41abf
2 files changed+31 added−6 removed
modified:click/core.py+28 added-5 removed
629 unmodified lines630 def parse_args(self, ctx, args):631 parser = self.make_parser(ctx)632 opts, args, param_order = parser.parse_args(args=args)633 634- if opts.get('$help') and not ctx.resilient_parsing:635- echo(ctx.get_help())636- ctx.exit()634+ # XXX: this logic requires a bit of explanation. As a change in635+ # 2.x we accidentally broke a pattern used in 1.x which was636+ # to customize the commands by passing more arguments. Because637+ # the help option however was moved away from regular handling638+ # to the front it meant that other arguments can no longer be639+ # handled at all. The workaround for 2.x is that we try this:640+ #641+ # 1. start with regular handling. If a click exception happens642+ # we show the help instead if wanted.643+ # 2. if every callback went through we try to show the help now.644+ #645+ # This restores the old behavior in practical terms while still646+ # special casing the help.647+ #648+ # Maybe this should be done differently?649 638- for param in iter_params_for_processing(param_order, self.params):639- value, args = param.handle_parse_result(ctx, opts, args)650+ def _try_show_help():651+ if opts.get('$help') and not ctx.resilient_parsing:652+ echo(ctx.get_help())653+ ctx.exit()654 655+ try:656+ for param in iter_params_for_processing(param_order, self.params):657+ value, args = param.handle_parse_result(ctx, opts, args)658+ except ClickException:659+ _try_show_help()660+ raise661+ else:662+ _try_show_help()663+664 if args and not self.allow_extra_args and not ctx.resilient_parsing:665 ctx.fail('Got unexpected extra argument%s (%s)'666 % (len(args) != 1 and 's' or '',667 ' '.join(map(make_str, args))))692 unmodified linesmodified:CHANGES+3 added-1 removed
23 unmodified lines24 25 Version 2.326 -----------27 28-(bugfix release, release date to be decided)28+(bugfix release, released on July 3rd 2014)29 30 - Fixed an incorrectly formatted help record for count options.'31 - Add support for ansi code stripping on Windows if colorama32 is not available.33+- restored the Click 1.0 handling of the help parameter for certain34+ edge cases.35 36 Version 2.237 -----------38 78 unmodified lines