Merge branch '6.x-maintenance'
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Markus Unterwaditzer · committed by Markus Unterwaditzer · parents 51fadbe, 891a223 · Browse files · 3 files·+46 added−3 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
3 files+46 added−3 removed
- tests:+43 added−1 removed
- other:+3 added−2 removed
Provenance
- Commit
764541f- Tree
9475391- Author
Markus Unterwaditzer <markus@unterwaditzer.net>- Committer
Markus Unterwaditzer <markus@unterwaditzer.net>- Parent 1
51fadbe- Parent 2
891a223
3 files changed+46 added−3 removed
modified:click/_bashcomplete.py+2 added-2 removed
28 unmodified lines29 30 31 def resolve_ctx(cli, prog_name, args):32 ctx = cli.make_context(prog_name, args, resilient_parsing=True)33- while ctx.args + ctx.protected_args and isinstance(ctx.command, MultiCommand):34- a = ctx.args + ctx.protected_args33+ while ctx.protected_args + ctx.args and isinstance(ctx.command, MultiCommand):34+ a = ctx.protected_args + ctx.args35 cmd = ctx.command.get_command(ctx, a[0])36 if cmd is None:37 return None38 ctx = cmd.make_context(a[0], a[1:], parent=ctx, resilient_parsing=True)45 unmodified linesmodified:tests/test_bashcomplete.py+43 added-1 removed
1 unmodified line2 3 import click4 from click._bashcomplete import get_choices5 6-def test_basic():6+7+def test_single_command():8+ @click.command()9+ @click.option('--local-opt')10+ def cli(local_opt):11+ pass12+13+ assert list(get_choices(cli, 'lol', [], '-')) == ['--local-opt']14+ assert list(get_choices(cli, 'lol', [], '')) == []15+16+17+def test_small_chain():18 @click.group()19 @click.option('--global-opt')20 def cli(global_opt):21 pass6 unmodified lines28 assert list(get_choices(cli, 'lol', [], '')) == ['sub']29 assert list(get_choices(cli, 'lol', [], '-')) == ['--global-opt']30 assert list(get_choices(cli, 'lol', ['sub'], '')) == []31 assert list(get_choices(cli, 'lol', ['sub'], '-')) == ['--local-opt']32+33+34+def test_long_chain():35+ @click.group('cli')36+ @click.option('--cli-opt')37+ def cli(cli_opt):38+ pass39+40+ @cli.group('asub')41+ @click.option('--asub-opt')42+ def asub(asub_opt):43+ pass44+45+ @asub.group('bsub')46+ @click.option('--bsub-opt')47+ def bsub(bsub_opt):48+ pass49+50+ @bsub.command('csub')51+ @click.option('--csub-opt')52+ def csub(csub_opt):53+ pass54+55+ assert list(get_choices(cli, 'lol', [], '-')) == ['--cli-opt']56+ assert list(get_choices(cli, 'lol', [], '')) == ['asub']57+ assert list(get_choices(cli, 'lol', ['asub'], '-')) == ['--asub-opt']58+ assert list(get_choices(cli, 'lol', ['asub'], '')) == ['bsub']59+ assert list(get_choices(cli, 'lol', ['asub', 'bsub'], '-')) == ['--bsub-opt']60+ assert list(get_choices(cli, 'lol', ['asub', 'bsub'], '')) == ['csub']61+ assert list(get_choices(cli, 'lol', ['asub', 'bsub', 'csub'], '-')) == ['--csub-opt']62+ assert list(get_choices(cli, 'lol', ['asub', 'bsub', 'csub'], '')) == []modified:CHANGES+1 added
18 unmodified lines19 20 (bugfix release; yet to be released)21 22 - Make `click.progressbar` work with `codecs.open` files. See #637.23+- Fix bug in bash completion with nested subcommands. See #639.24 25 Version 6.626 -----------27 331 unmodified lines