-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Closed
Description
Adding a default value to an argument of the Choice type will hose autocompletion. Can be tested as follows:
Slightly modifying test_argument_choice test example in test_bashcomplete.py to add a default argument:
def test_argument_choice():
@click.command()
@click.argument('arg1', required=False, type=click.Choice(['arg11', 'arg12']))
@click.argument('arg2', required=False, type=click.Choice(['arg21', 'arg22']), default='arg21')
@click.argument('arg3', required=False, type=click.Choice(['arg', 'argument']))
def cli():
pass
assert list(get_choices(cli, 'lol', [], '')) == ['arg11', 'arg12']
assert list(get_choices(cli, 'lol', [], 'arg')) == ['arg11', 'arg12']
assert list(get_choices(cli, 'lol', ['arg11'], '')) == ['arg21', 'arg22']
assert list(get_choices(cli, 'lol', ['arg12', 'arg21'], '')) == ['arg', 'argument']
assert list(get_choices(cli, 'lol', ['arg12', 'arg21'], 'argu')) == ['argument']
Result:
Traceback (most recent call last):
File "test_compl.py", line 19, in <module>
test_argument_choice()
File "test_compl.py", line 14, in test_argument_choice
assert list(get_choices(cli, 'lol', ['arg11'], '')) == ['arg21', 'arg22']
AssertionError