Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
libklein opened this issue Sep 2, 2024 · 0 comments
Open

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

libklein opened this issue Sep 2, 2024 · 0 comments

Comments

@libklein
Copy link

libklein commented Sep 2, 2024

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 (fastapi/typer#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

def process_value(self, ctx: Context, value: t.Any) -> t.Any:

Please comment accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant