click icon indicating copy to clipboard operation
click copied to clipboard

Allow nargs=-1 in options with a non-whitespace separator

Open libklein opened this issue 5 months ago • 0 comments

What should this feature do?

Allow parsing command line options with an arbitrary number of values. This would allow to type

cli arg1 arg2 --option 1, 2, 3

instead of the more tedious and less familiar

cli arg1 arg2 --option 1 --option 2 --option 3

This has been suggested in #2537. This request is different in that options with nargs=-1 would require an additional separator parameter, that has to be set to a non-whitespace character. This would mitigate the ambiguity issues of #2537.

I have contributed this feature to a downstream CLI library (https://github.com/fastapi/typer/pull/800) and would be happy to contribute the changes to click itself if this is something that you would like to see supported. The changes essentially imply adding a few lines to https://github.com/pallets/click/blob/4a758f5c38636ecd9d030356d85bcca3d8fbd0ca/src/click/core.py#L2267

Please comment accordingly.

libklein avatar Sep 02 '24 22:09 libklein