-
-
Notifications
You must be signed in to change notification settings - Fork 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
Document that multi-value options do not get along with trailing subcommands #1721
Comments
Yeah, this is a known problem, but I think we should document it better though. |
multiple(true)
top-level flags do not interact well with subcommands.
Check this for more info, #1610 and please give us feedback if that explains your issue. I am thinking of pointing to that issue in the docs for |
Is there a way to implement an option that would require each value for the multiple flag to be accompanied with the flag? That is to disable this implicit token consumption? I’m sure most of the users will be plenty happy with EDIT: That is, I originally expected EDIT: Ah, I see, its |
The more I think about it, the more I get assured that we need two different methods for that:
|
I got mostly the behaviour I want by setting |
But it should be documented better nonetheless. |
@CreepySkeleton could we check if the next token matches a subcommand and if it does stop parsing the argument and instead parse the subcommand? Essentially, remove this line. It looks like this used to be the behavior, but was changed due to #1031. My personal opinion is that handling (1) "multi-value options with subcommands" is more important than (2) "argument value taking precedence over subcommand with the same name". The reasons being:
|
We are happy to add support for something like this with an AppSetting. But it would have to be something for later and not a priority for 3.0 |
If we remove that line, positional with multiple values would stop working at all; the logic over there looks far more complicated.
I'd go for changing the default behavior (because 2) and introducing an |
I wouldn't change the default but introduce an |
Maybe we should conduct a survey of sorts? Ask on users forum or something, "Here's the problem, which default would you like and why?". Our opinions... well, they are our opinions, and we are not the majority here, despite we are indeed the greatest! |
Adding |
No no, these are different problems.
To be honest, I personally don't like this design. I consider this design error prone and pretty non-intuitive, I would not write such a CLI and I would try to dissuade people from this sort of desing. But, even thought I'm admittedly a very wise person, I'm not the whole community. This is why I'm proposing to ask. Just to hear people out. If we find their argument not so compelling or opinions will differ significantly, we will just pull our Dictatorship card and chant "Succumb to our will!". |
Rust Version
rustc 1.43.0-nightly (7760cd0fb 2020-02-19)
Code
Steps to reproduce the issue
cargo run -- --config 'banana=true' test
cargo run -- --config='banana=true' test
Affected Version of
clap*
2.33
Actual Behavior Summary
clap will greedily consume values into space-separated
--config
flag.Expected Behavior Summary
I’m not sure how common place this behaviour (
--long arg1 arg2
parsing as--long arg1 --long arg2
) is. Definitely was unexpected to me.The text was updated successfully, but these errors were encountered: