click icon indicating copy to clipboard operation
click copied to clipboard

Indicate multiple use options in help

Open ofek opened this issue 1 year ago • 1 comments

I think it would be nice to append a ... to the metavar when multiple is true. Using curl as an example, -H TEXT would become -H TEXT....

ofek avatar Sep 18 '24 18:09 ofek

Can you please explain your overall reasoning? Maybe I am misunderstanding, but couldn't you do this -


@click.command()
@click.option('--color', multiple=True, metavar='<COLOR>', help='Specify a color')
@click.option('--size', multiple=True, metavar='<SIZE>', help='Specify a size')
def cli(color, size):
    click.echo(f'You selected the colors: {", ".join(color)}')
    click.echo(f'You selected the sizes: {", ".join(size)}')

if __name__ == '__main__':
    cli()

Then you would get -

$ python script.py --color red --color green --color blue --size small --size large
You selected the colors: red, green, blue
You selected the sizes: small, large

swills1 avatar Nov 30 '24 05:11 swills1