Skip to content
Myr

test_bashcomplete.py

This file

Path

tests/test_bashcomplete.py

409 lines · 14.9 KiB · Python

Last changed by

Merge pull request #1061 from stopthatcow/feature/1058David Lordbefore adoption752c5e4

History of this file

Take it

The walk stopped after 200 commits: lines older than 430c50a point at it.

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 1–6why, one step back
1# -*- coding: utf-8 -*-
23import click4from click._bashcomplete import get_choices56

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 7–15why, one step back
7def choices_without_help(cli, args, incomplete):
8 completions = get_choices(cli, 'dummy', args, incomplete)9 return [c[0] for c in completions]101112def choices_with_help(cli, args, incomplete):13 return list(get_choices(cli, 'dummy', args, incomplete))1415

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 16–21why, one step back
16def test_single_command():
17 @click.command()18 @click.option('--local-opt')19 def cli(local_opt):20 pass21

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 22–23why, one step back
22 assert choices_without_help(cli, [], '-') == ['--local-opt']
23 assert choices_without_help(cli, [], '') == []

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 24–31why, one step back
24
2526def test_boolean_flag():27 @click.command()28 @click.option('--shout/--no-shout', default=False)29 def cli(local_opt):30 pass31

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 32why, one step back
32 assert choices_without_help(cli, [], '-') == ['--shout', '--no-shout']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 33–45why, one step back
33
3435def test_multi_value_option():36 @click.group()37 @click.option('--pos', nargs=2, type=float)38 def cli(local_opt):39 pass4041 @cli.command()42 @click.option('--local-opt')43 def sub(local_opt):44 pass45

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 46–49why, one step back
46 assert choices_without_help(cli, [], '-') == ['--pos']
47 assert choices_without_help(cli, ['--pos'], '') == []48 assert choices_without_help(cli, ['--pos', '1.0'], '') == []49 assert choices_without_help(cli, ['--pos', '1.0', '1.0'], '') == ['sub']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 50–57why, one step back
50
5152def test_multi_option():53 @click.command()54 @click.option('--message', '-m', multiple=True)55 def cli(local_opt):56 pass57

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 58–59why, one step back
58 assert choices_without_help(cli, [], '-') == ['--message', '-m']
59 assert choices_without_help(cli, ['-m'], '') == []

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 60–72why, one step back
60
6162def test_small_chain():63 @click.group()64 @click.option('--global-opt')65 def cli(global_opt):66 pass6768 @cli.command()69 @click.option('--local-opt')70 def sub(local_opt):71 pass72

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 73–76why, one step back
73 assert choices_without_help(cli, [], '') == ['sub']
74 assert choices_without_help(cli, [], '-') == ['--global-opt']75 assert choices_without_help(cli, ['sub'], '') == []76 assert choices_without_help(cli, ['sub'], '-') == ['--local-opt']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 77–94why, one step back
77
7879def test_long_chain():80 @click.group('cli')81 @click.option('--cli-opt')82 def cli(cli_opt):83 pass8485 @cli.group('asub')86 @click.option('--asub-opt')87 def asub(asub_opt):88 pass8990 @asub.group('bsub')91 @click.option('--bsub-opt')92 def bsub(bsub_opt):93 pass94

Merge pull request #755 from stopthatcow/feature/bash_autocompletion_6.6Markus Unterwaditzerbefore adoption5f2ff4f

lines 95–97why, one step back
95 COLORS = ['red', 'green', 'blue']
96 def get_colors(ctx, args, incomplete):97 for c in COLORS:

Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849

lines 98–99why, one step back
98 if c.startswith(incomplete):
99 yield c

Merge pull request #755 from stopthatcow/feature/bash_autocompletion_6.6Markus Unterwaditzerbefore adoption5f2ff4f

line 100why, one step back
100

Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849

lines 101–105why, one step back
101 def search_colors(ctx, args, incomplete):
102 for c in COLORS:103 if incomplete in c:104 yield c105

Merge pull request #755 from stopthatcow/feature/bash_autocompletion_6.6Markus Unterwaditzerbefore adoption5f2ff4f

lines 106–107why, one step back
106 CSUB_OPT_CHOICES = ['foo', 'bar']
107 CSUB_CHOICES = ['bar', 'baz']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

line 108why, one step back
108 @bsub.command('csub')

Merge pull request #755 from stopthatcow/feature/bash_autocompletion_6.6Markus Unterwaditzerbefore adoption5f2ff4f

lines 109–110why, one step back
109 @click.option('--csub-opt', type=click.Choice(CSUB_OPT_CHOICES))
110 @click.option('--csub', type=click.Choice(CSUB_CHOICES))

Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849

line 111why, one step back
111 @click.option('--search-color', autocompletion=search_colors)

Merge pull request #755 from stopthatcow/feature/bash_autocompletion_6.6Markus Unterwaditzerbefore adoption5f2ff4f

lines 112–113why, one step back
112 @click.argument('color', autocompletion=get_colors)
113 def csub(csub_opt, color):

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 114–115why, one step back
114 pass
115

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 116–129why, one step back
116 assert choices_without_help(cli, [], '-') == ['--cli-opt']
117 assert choices_without_help(cli, [], '') == ['asub']118 assert choices_without_help(cli, ['asub'], '-') == ['--asub-opt']119 assert choices_without_help(cli, ['asub'], '') == ['bsub']120 assert choices_without_help(cli, ['asub', 'bsub'], '-') == ['--bsub-opt']121 assert choices_without_help(cli, ['asub', 'bsub'], '') == ['csub']122 assert choices_without_help(cli, ['asub', 'bsub', 'csub'], '-') == ['--csub-opt', '--csub', '--search-color']123 assert choices_without_help(cli, ['asub', 'bsub', 'csub', '--csub-opt'], '') == CSUB_OPT_CHOICES124 assert choices_without_help(cli, ['asub', 'bsub', 'csub'], '--csub') == ['--csub-opt', '--csub']125 assert choices_without_help(cli, ['asub', 'bsub', 'csub', '--csub'], '') == CSUB_CHOICES126 assert choices_without_help(cli, ['asub', 'bsub', 'csub', '--csub-opt'], 'f') == ['foo']127 assert choices_without_help(cli, ['asub', 'bsub', 'csub'], '') == COLORS128 assert choices_without_help(cli, ['asub', 'bsub', 'csub'], 'b') == ['blue']129 assert choices_without_help(cli, ['asub', 'bsub', 'csub', '--search-color'], 'een') == ['green']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 130–131why, one step back
130
131

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

lines 132–134why, one step back
132def test_chaining():
133 @click.group('cli', chain=True)134 @click.option('--cli-opt')

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 135–136why, one step back
135 @click.argument('arg', type=click.Choice(['cliarg1', 'cliarg2']))
136 def cli(cli_opt, arg):

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

lines 137–138why, one step back
137 pass
138

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 139why, one step back
139 @cli.command()

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

lines 140–143why, one step back
140 @click.option('--asub-opt')
141 def asub(asub_opt):142 pass143

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 144why, one step back
144 @cli.command(help='bsub help')

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

line 145why, one step back
145 @click.option('--bsub-opt')

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 146why, one step back
146 @click.argument('arg', type=click.Choice(['arg1', 'arg2']))

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

lines 147–149why, one step back
147 def bsub(bsub_opt, arg):
148 pass149

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 150why, one step back
150 @cli.command()

Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849

line 151why, one step back
151 @click.option('--csub-opt')

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 152why, one step back
152 @click.argument('arg', type=click.Choice(['carg1', 'carg2']), default='carg1')

Merge pull request #806 from stopthatcow/feature/790Markus Unterwaditzerbefore adoption5210849

lines 153–155why, one step back
153 def csub(csub_opt, arg):
154 pass155

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 156why, one step back
156 assert choices_without_help(cli, [], '-') == ['--cli-opt']

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 157–167why, one step back
157 assert choices_without_help(cli, [], '') == ['cliarg1', 'cliarg2']
158 assert choices_without_help(cli, ['cliarg1', 'asub'], '-') == ['--asub-opt']159 assert choices_without_help(cli, ['cliarg1', 'asub'], '') == ['bsub', 'csub']160 assert choices_without_help(cli, ['cliarg1', 'bsub'], '') == ['arg1', 'arg2']161 assert choices_without_help(cli, ['cliarg1', 'asub', '--asub-opt'], '') == []162 assert choices_without_help(cli, ['cliarg1', 'asub', '--asub-opt', '5', 'bsub'], '-') == ['--bsub-opt']163 assert choices_without_help(cli, ['cliarg1', 'asub', 'bsub'], '-') == ['--bsub-opt']164 assert choices_without_help(cli, ['cliarg1', 'asub', 'csub'], '') == ['carg1', 'carg2']165 assert choices_without_help(cli, ['cliarg1', 'bsub', 'arg1', 'csub'], '') == ['carg1', 'carg2']166 assert choices_without_help(cli, ['cliarg1', 'asub', 'csub'], '-') == ['--csub-opt']167 assert choices_with_help(cli, ['cliarg1', 'asub'], 'b') == [('bsub', 'bsub help')]

Merge branch 'stopthatcow-feature/fix_chained_args_completion'Markus Unterwaditzerbefore adoptionb224988

lines 168–169why, one step back
168
169

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 170–171why, one step back
170def test_argument_choice():
171 @click.command()

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 172–174why, one step back
172 @click.argument('arg1', required=True, type=click.Choice(['arg11', 'arg12']))
173 @click.argument('arg2', type=click.Choice(['arg21', 'arg22']), default='arg21')174 @click.argument('arg3', type=click.Choice(['arg', 'argument']), default='arg')

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 175–177why, one step back
175 def cli():
176 pass177

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 178–182why, one step back
178 assert choices_without_help(cli, [], '') == ['arg11', 'arg12']
179 assert choices_without_help(cli, [], 'arg') == ['arg11', 'arg12']180 assert choices_without_help(cli, ['arg11'], '') == ['arg21', 'arg22']181 assert choices_without_help(cli, ['arg12', 'arg21'], '') == ['arg', 'argument']182 assert choices_without_help(cli, ['arg12', 'arg21'], 'argu') == ['argument']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 183–186why, one step back
183
184185def test_option_choice():186 @click.command()

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 187why, one step back
187 @click.option('--opt1', type=click.Choice(['opt11', 'opt12']), help='opt1 help')

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 188why, one step back
188 @click.option('--opt2', type=click.Choice(['opt21', 'opt22']), default='opt21')

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 189–192why, one step back
189 @click.option('--opt3', type=click.Choice(['opt', 'option']))
190 def cli():191 pass192

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 193–207why, one step back
193 assert choices_with_help(cli, [], '-') == [('--opt1', 'opt1 help'),
194 ('--opt2', None),195 ('--opt3', None)]196 assert choices_without_help(cli, [], '--opt') == ['--opt1', '--opt2', '--opt3']197 assert choices_without_help(cli, [], '--opt1=') == ['opt11', 'opt12']198 assert choices_without_help(cli, [], '--opt2=') == ['opt21', 'opt22']199 assert choices_without_help(cli, ['--opt2'], '=') == ['opt21', 'opt22']200 assert choices_without_help(cli, ['--opt2', '='], 'opt') == ['opt21', 'opt22']201 assert choices_without_help(cli, ['--opt1'], '') == ['opt11', 'opt12']202 assert choices_without_help(cli, ['--opt2'], '') == ['opt21', 'opt22']203 assert choices_without_help(cli, ['--opt1', 'opt11', '--opt2'], '') == ['opt21', 'opt22']204 assert choices_without_help(cli, ['--opt2', 'opt21'], '-') == ['--opt1', '--opt3']205 assert choices_without_help(cli, ['--opt1', 'opt11'], '-') == ['--opt2', '--opt3']206 assert choices_without_help(cli, ['--opt1'], 'opt') == ['opt11', 'opt12']207 assert choices_without_help(cli, ['--opt3'], 'opti') == ['option']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

line 208why, one step back
208

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 209why, one step back
209 assert choices_without_help(cli, ['--opt1', 'invalid_opt'], '-') == ['--opt2', '--opt3']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 210–219why, one step back
210
211212def test_option_and_arg_choice():213 @click.command()214 @click.option('--opt1', type=click.Choice(['opt11', 'opt12']))215 @click.argument('arg1', required=False, type=click.Choice(['arg11', 'arg12']))216 @click.option('--opt2', type=click.Choice(['opt21', 'opt22']))217 def cli():218 pass219

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 220–223why, one step back
220 assert choices_without_help(cli, ['--opt1'], '') == ['opt11', 'opt12']
221 assert choices_without_help(cli, [''], '--opt1=') == ['opt11', 'opt12']222 assert choices_without_help(cli, [], '') == ['arg11', 'arg12']223 assert choices_without_help(cli, ['--opt2'], '') == ['opt21', 'opt22']

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 224–225why, one step back
224 assert choices_without_help(cli, ['arg11'], '--opt') == ['--opt1', '--opt2']
225 assert choices_without_help(cli, [], '--opt') == ['--opt1', '--opt2']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 226–234why, one step back
226
227228def test_boolean_flag_choice():229 @click.command()230 @click.option('--shout/--no-shout', default=False)231 @click.argument('arg', required=False, type=click.Choice(['arg1', 'arg2']))232 def cli(local_opt):233 pass234

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 235–236why, one step back
235 assert choices_without_help(cli, [], '-') == ['--shout', '--no-shout']
236 assert choices_without_help(cli, ['--shout'], '') == ['arg1', 'arg2']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 237–245why, one step back
237
238239def test_multi_value_option_choice():240 @click.command()241 @click.option('--pos', nargs=2, type=click.Choice(['pos1', 'pos2']))242 @click.argument('arg', required=False, type=click.Choice(['arg1', 'arg2']))243 def cli(local_opt):244 pass245

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 246–249why, one step back
246 assert choices_without_help(cli, ['--pos'], '') == ['pos1', 'pos2']
247 assert choices_without_help(cli, ['--pos', 'pos1'], '') == ['pos1', 'pos2']248 assert choices_without_help(cli, ['--pos', 'pos1', 'pos2'], '') == ['arg1', 'arg2']249 assert choices_without_help(cli, ['--pos', 'pos1', 'pos2', 'arg1'], '') == []

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 250–258why, one step back
250
251252def test_multi_option_choice():253 @click.command()254 @click.option('--message', '-m', multiple=True, type=click.Choice(['m1', 'm2']))255 @click.argument('arg', required=False, type=click.Choice(['arg1', 'arg2']))256 def cli(local_opt):257 pass258

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 259–261why, one step back
259 assert choices_without_help(cli, ['-m'], '') == ['m1', 'm2']
260 assert choices_without_help(cli, ['-m', 'm1', '-m'], '') == ['m1', 'm2']261 assert choices_without_help(cli, ['-m', 'm1'], '') == ['arg1', 'arg2']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 262–265why, one step back
262
263264def test_variadic_argument_choice():265 @click.command()

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 266why, one step back
266 @click.option('--opt', type=click.Choice(['opt1', 'opt2']))

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 267–270why, one step back
267 @click.argument('src', nargs=-1, type=click.Choice(['src1', 'src2']))
268 def cli(local_opt):269 pass270

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 271why, one step back
271 assert choices_without_help(cli, ['src1', 'src2'], '') == ['src1', 'src2']

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 272–274why, one step back
272 assert choices_without_help(cli, ['src1', 'src2'], '--o') == ['--opt']
273 assert choices_without_help(cli, ['src1', 'src2', '--opt'], '') == ['opt1', 'opt2']274 assert choices_without_help(cli, ['src1', 'src2'], '') == ['src1', 'src2']

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 275–276why, one step back
275
276

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 277–298why, one step back
277def test_variadic_argument_complete():
278279 def _complete(ctx, args, incomplete):280 return ['abc', 'def', 'ghi', 'jkl', 'mno', 'pqr', 'stu', 'vwx', 'yz']281282 @click.group()283 def entrypoint():284 pass285286 @click.command()287 @click.option('--opt', autocompletion=_complete)288 @click.argument('arg', nargs=-1)289 def subcommand(opt, arg):290 pass291292 entrypoint.add_command(subcommand)293294 assert choices_without_help(entrypoint, ['subcommand', '--opt'], '') == _complete(0,0,0)295 assert choices_without_help(entrypoint, ['subcommand', 'whatever', '--opt'], '') == _complete(0,0,0)296 assert choices_without_help(entrypoint, ['subcommand', 'whatever', '--opt', 'abc'], '') == []297298

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 299–303why, one step back
299def test_long_chain_choice():
300 @click.group()301 def cli():302 pass303

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 304why, one step back
304 @cli.group()

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 305–306why, one step back
305 @click.option('--sub-opt', type=click.Choice(['subopt1', 'subopt2']))
306 @click.argument('sub-arg', required=False, type=click.Choice(['subarg1', 'subarg2']))

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 307why, one step back
307 def sub(sub_opt, sub_arg):

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 308–309why, one step back
308 pass
309

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 310why, one step back
310 @sub.command(short_help='bsub help')

Merge pull request #681 from pgkelley4/masterMarkus Unterwaditzerbefore adoption430c50a

lines 311–316why, one step back
311 @click.option('--bsub-opt', type=click.Choice(['bsubopt1', 'bsubopt2']))
312 @click.argument('bsub-arg1', required=False, type=click.Choice(['bsubarg1', 'bsubarg2']))313 @click.argument('bbsub-arg2', required=False, type=click.Choice(['bbsubarg1', 'bbsubarg2']))314 def bsub(bsub_opt):315 pass316

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 317–326why, one step back
317 @sub.group('csub')
318 def csub():319 pass320321 @csub.command()322 def dsub():323 pass324325 assert choices_with_help(cli, ['sub', 'subarg1'], '') == [('bsub', 'bsub help'), ('csub', '')]326 assert choices_without_help(cli, ['sub'], '') == ['subarg1', 'subarg2']

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

lines 327–328why, one step back
327 assert choices_without_help(cli, ['sub', '--sub-opt'], '') == ['subopt1', 'subopt2']
328 assert choices_without_help(cli, ['sub', '--sub-opt', 'subopt1'], '') == \

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 329why, one step back
329 ['subarg1', 'subarg2']

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 330why, one step back
330 assert choices_without_help(cli,

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 331why, one step back
331 ['sub', '--sub-opt', 'subopt1', 'subarg1', 'bsub'], '-') == ['--bsub-opt']

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 332why, one step back
332 assert choices_without_help(cli,

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

line 333why, one step back
333 ['sub', '--sub-opt', 'subopt1', 'subarg1', 'bsub'], '') == ['bsubarg1', 'bsubarg2']

Merge pull request #869 from stopthatcow/feature/866David Lordbefore adoptiond37ff75

line 334why, one step back
334 assert choices_without_help(cli,

Merge pull request #930 from stopthatcow/feature/925David Lordbefore adoptionbe28b6c

lines 335–373why, one step back
335 ['sub', '--sub-opt', 'subopt1', 'subarg1', 'bsub', '--bsub-opt'], '') == \
336 ['bsubopt1', 'bsubopt2']337 assert choices_without_help(cli,338 ['sub', '--sub-opt', 'subopt1', 'subarg1', 'bsub', '--bsub-opt', 'bsubopt1', 'bsubarg1'],339 '') == ['bbsubarg1', 'bbsubarg2']340 assert choices_without_help(cli,341 ['sub', '--sub-opt', 'subopt1', 'subarg1', 'csub'],342 '') == ['dsub']343344345def test_chained_multi():346 @click.group()347 def cli():348 pass349350 @cli.group()351 def sub():352 pass353354 @sub.group()355 def bsub():356 pass357358 @sub.group(chain=True)359 def csub():360 pass361362 @csub.command()363 def dsub():364 pass365366 @csub.command()367 def esub():368 pass369370 assert choices_without_help(cli, ['sub'], '') == ['bsub', 'csub']371 assert choices_without_help(cli, ['sub'], 'c') == ['csub']372 assert choices_without_help(cli, ['sub', 'csub'], '') == ['dsub', 'esub']373 assert choices_without_help(cli, ['sub', 'csub', 'dsub'], '') == ['esub']

Merge pull request #1061 from stopthatcow/feature/1058David Lordbefore adoption752c5e4

lines 374–409why, one step back
374
375376def test_hidden():377 @click.group()378 @click.option('--name', hidden=True)379 @click.option('--choices', type=click.Choice([1, 2]), hidden=True)380 def cli(name):381 pass382383 @cli.group(hidden=True)384 def hgroup():385 pass386387 @hgroup.group()388 def hgroupsub():389 pass390391 @cli.command()392 def asub():393 pass394395 @cli.command(hidden=True)396 @click.option('--hname')397 def hsub():398 pass399400 assert choices_without_help(cli, [], '--n') == []401 assert choices_without_help(cli, [], '--c') == []402 # If the user exactly types out the hidden param, complete its options.403 assert choices_without_help(cli, ['--choices'], '') == [1, 2]404 assert choices_without_help(cli, [], '') == ['asub']405 assert choices_without_help(cli, [], '') == ['asub']406 assert choices_without_help(cli, [], 'h') == []407 # If the user exactly types out the hidden command, complete its subcommands.408 assert choices_without_help(cli, ['hgroup'], '') == ['hgroupsub']409 assert choices_without_help(cli, ['hsub'], '--h') == ['--hname']