-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Multiple values separated by a delimiter _only_? #546
Comments
Currently, there isn't a way to force the use of a delimiter. That is something that could be added. But there are few other things about this scenario too: Is there a limit on the number of values for I could consider this a bug, so-to-speak. i.e. if a delimiter is present, parsing something after a space probably shouldn't be part of the same value group. This still doesn't help your scenario 2 though. To go along with the above "bug" is parsing something like So, would solving those two bugs suffice, or would a
This would allow you to do
Edit: thinking about it more, I'm good adding the |
Thank you for your response. In my case it's strictly 1 or 2 values for |
…trailing space as values Imagine two args, an options `-o` and a positionanl arg `<file>` where the option allows multiple values. Prior to this change the following (incorrect) parses were occurring: ``` $ prog -o=1 some.txt o = 1, file file = ``` This change stops parsing values at the space, only if the `=` was used. ``` $ prog -o=1 some.txt o = 1 file = some.txt ``` Multiple values are still supported via value delimiters ``` $ prog -o=1,2 some.txt o = 1, 2 file = some.txt ``` Relates to #546
…es after a trailing space Imagine two args, an option `-o` which accepts mutliple values, and a positional arg `<file>`. Prior to this change the following (incorrect) parses would have happened: ``` $ prog -o 1,2 some.txt o = 1, 2, file file = ``` Only when delimters are used, spaces stop parsing values for the option. The follow are now correct ``` $ prog -o 1,2 some.txt o = 1, 2 file = some.txt $ prog some.txt -o 1 2 o = 1, 2 file = some.txt ``` This still has the bi-product of: ``` $ prog -o 1 2 some.txt o = 1, 2, some.txt file = ``` This is simply a CLI design and documentation issue (i.e. don't allow options with unlimited multiple values with positionaln args, or clearly document that positional args go first). This will also be helped by the upcoming `Arg::require_delimiter` Relates to #546
#547 implements those two bug fixes and will be uploaded to crates.io as v2.7.1, then I'll add the |
Fantastic! Thank you! |
I want to keep this open just a tracking issue for that, until the PR merges. |
This will be fully implemented with #551 |
I'm trying to make an arg that accepts one or two comma-delimited values, and also accept unnamed (index) argument after that.
prog -q 1,2 file # OK: parses as q=[1,2]; input=file
prog -q 1 file # should parse as q=[1]; input=file; but parses as q=[1,file]; input missing
The problem is that multiple arguments allow spaces, which causes ambiguity. I don't know how to disable that.
The text was updated successfully, but these errors were encountered: