-
-
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
[derive] Vec<String> consumes all the arguments #3066
Comments
Yes, a sufficiently smart parser could handle back tracking for required positional arguments. Unfortunately, that is a very specialized case and gets ambiguous when dealing with optional positionals, etc. Instead, we provide a lot of warnings when using It is also likely that |
With that said, any documentation or behavior changes that you think would help or should we consider this Issue resolved? |
I did solve my problem by listening to your advice and reading about in the docs and the issue you pointed out. These adjustments did the trick: #[clap(long, multiple_occurrences(true), number_of_values = 1)]
pub field: Option<Vec<String>>, Here are 2 things I think would have helped:
Here is an example: #[clap(short, long, default_value = "-")]
pub separator: Option<String>, The build output $ cargo build
error: default_value is meaningless for Option
--> src/cli.rs:26:25
|
26 | #[clap(short, long, default_value = "-")]
| ^^^^^^^^^^^^^ |
With 3.0.0-rc.0, which came out earlier today, As for the error "error: default_value is meaningless for Option", its basically saying that your |
Héhé, I understood the error message for the option. I was just suggested to implement a warning message using a similar mechanism for |
Please complete the following tasks
Rust Version
rustc 1.54.0 (a178d0322 2021-07-26)
Clap Version
v3.0.0-beta.5
Minimal reproducible code
The problem can be reproduced using the "example.rs" example.
Steps to reproduce the bug with the above code
Since the example expects 2 mandatory arguments, the
--optv
flag should know how to ignore them.The behavior is correct when we add an extra flag before the mandatory arguments.
$ cargo run -q --example example -- --optv opt_a opt_b opt_c -d in_file out_file ""
Actual Behaviour
See above.
Expected Behaviour
See above.
Additional Context
No response
Debug Output
No response
The text was updated successfully, but these errors were encountered: