-
-
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
requires_all does not display all missing requirements #1158
Comments
To clarify, this is ArgGroup.requires_all |
I'm trying to set up a command line something like: but I get:
and
In this case, --conf is not required or missing. In fact, including it would cause a conflict. Here's my code:
|
Apologies, I've confirmed this bug. I'm in a heated battle with getting v3 out the door (which will include this bug fix) but I might be able to squeeze the part of this bug fix that will at least remove |
…show up as required Prior to this commit if one had two requirements which conflicted with each other, and an error was generated due to a totally seperate argument, BOTH required but conflicting args would show up in the help message as "missing but required" This is now fixed and the *used* required arg shows up, but the conflicting required arg has been dropped. Closes #1158
…show up as required Prior to this commit if one had two requirements which conflicted with each other, and an error was generated due to a totally seperate argument, BOTH required but conflicting args would show up in the help message as "missing but required" This is now fixed and the *used* required arg shows up, but the conflicting required arg has been dropped. Closes #1158
This is fixed in #1164 however, the usage string isn't exactly what you want. So I would recommend using a custom usage string. The behaviour is correct though. let matches = App::new("example")
.usage("example <--config [FILE] | -x [X] -y [Y] -z [Z]>")
.arg(Arg::from_usage("-c, --config [FILE] 'Custom config file.'")
.required_unless("ID")
.conflicts_with("ID"))
.arg(Arg::from_usage("[ID] 'ID'")
.required_unless("config")
.conflicts_with("config")
.requires_all(&["x", "y", "z"]))
.arg(Arg::from_usage("-x [X] 'X'"))
.arg(Arg::from_usage("-y [Y] 'Y'"))
.arg(Arg::from_usage("-z [Z] 'Z'"))
.get_matches(); |
Fixes requirements and conflicts on the v3 branch Closes #1158
Rust Version
1.23
Affected Version of clap
2.29.2
Expected Behavior Summary
When an agument has a requires_all list, and that argument is present but multiple of its required arguments are missing, clap should print an error message that includes all missing required arguments.
Actual Behavior Summary
clap will print out just one of the missing arguments. The user has to repeat the command over and over, adding one missing argument at a time.
The text was updated successfully, but these errors were encountered: