Click: Bash complete fails for click.Choice() arguments

Created on 11 Mar 2016  路  2Comments  路  Source: pallets/click

Arguments of type 'click.Choice' are properly constrained on invocation, but do not show up in bash tab completion.

dws.py:

...

SETTINGS = [
    "auto_start",
    "disk_size",
    "environment"
]

@click.group()
def cli():
    pass


@cli.command()
@click.argument('setting', type=click.Choice(SETTINGS), nargs=1)
@click.argument('value', nargs=1)
def set(setting, value):
    '''
    Persists a named setting.  Supported settings:
    ["environment", "add_to_chef"]
    '''
    click.echo("Persisting a setting: %s=%s" % (setting, value))

...

dws <tab> <tab> reveals the set function as expected, but not the allowable values from the SETTINGS list.

Most helpful comment

Is there any plan to incorporate this feature? I'd be very interested in this.

All 2 comments

The current click bashcompletion doesn't do any kind of completion of the _values_ of options and arguments.

Is there any plan to incorporate this feature? I'd be very interested in this.

Was this page helpful?
0 / 5 - 0 ratings