-
-
Notifications
You must be signed in to change notification settings - Fork 672
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
DOC: Documentation of passing multiple values in "option" vs "argument" isn't sufficiently explicit #554
Comments
I just encountered this issue too. This is definitely a feature I'd absolutely love to have (white space or comma separated lists) I'm really not a fan of having to re-write the commands like Either
Not sure where to put in a request for this, or if its been stated that it is not going to be implemented! Thanks so much to all contributers of this repo anyhow, found it a few days ago and switched all my CLI workflows to it almost immediately! Love it! |
I see that the PR is passing and has been accepted. Any idea when this will be merged? I currently implement this via a workaround in my code, but this would allow for much cleaner implementation while using the library. |
Hey there, I coded a quick workaround for the "Typer doesn't support whitespace-separated multi-value options" (sorry won't have time for a PR) after moving from argparse to typer for a big project. My users are used to running 'app some_command --filters filter1 filter2 filter3 --envs env1 env2 env3' and I thought using 'app some_command --filters filter1 --filters filter2 --filters filter3 --envs env1 --envs env2 --envs env3' would be too much of a gap/pain for them and I, so I simply wrote a quick function that preprocesses the sysargv from whitespace-separated multi-value options to the typer format before they're given to typer. For anyone who needs it as well:
Note that the sysargv preprocessing above won't be taken into account in your test files if you use the typer.testing CliRunner, so in your tests you'll have to use the typer format instead. Happy long weekend to all of you |
Hi @DvdNss, thanks for the contribution! I think that the original reason for not supporting this is, as you've already pointed out in the comment of your code, that this forces arguments to be specified before options on the command line to avoid potential ambiguity between arguments and options. A similar issue has been raised in click: pallets/click#2537. I am unsure whether this functionality is desired in typer @svlandeg. |
Note to solve the potential ambiguity issue, there is a widely used convention (e.g. by See e.g. https://www.gnu.org/prep/standards/html_node/Command_002dLine-Interfaces.html |
Privileged issue
Issue Content
I was looking into passing multiple (N>=1, all N >=1 allowed) white space separated values via an option.
This does not seem possible at the moment, but the documentation wasn't very clear. It's only possible to pass an exact number of space separated values via an option, but not a list: https://typer.tiangolo.com/tutorial/multiple-values/options-with-multiple-values/
Multiple values are only possible via argument, yet the documentation for the two types reads almost identical (at least the first few paragraphs): https://typer.tiangolo.com/tutorial/multiple-values/arguments-with-multiple-values/
It would be good to be precise in the first paragraph about the fact that options don't allow you to pass N>=1 values.
Maybe one could accept multiple values by specifying a separator that's not white space, like comma-separated - but that's a feature request in a bit different direction.
The text was updated successfully, but these errors were encountered: