-
-
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
global opts that take a value cannot be mixed with subcommand #1570
Comments
not sure if this is the same issue or a different issue but I'm seeing something similar where a global arg isn't propogating to the use clap::{App, Arg};
fn main() {
let matches = App::new("myapp")
.subcommand(
App::new("test")
.arg(
Arg::with_name("global-opt")
.number_of_values(1)
.short('A')
.global(true),
)
.subcommand(App::new("testt")),
)
.get_matches_from(vec!["myapp", "test", "testt", "-Aone"]);
let gs = matches.value_of("global-opt");
assert_eq!(gs, Some("one"));
} The assert_eq here fails. |
It is the same issue. Thanks for the reports guys. Unfortunately we won't get to fix this until 3.0 is out. |
Hey, is this change still in the v3 roadmap? |
If you look at the milestone. It's not scheduled for v3 release. But afterwards. |
#3938 is a related issue for how to deal with global args appearing before and after a subcommand |
Rust Version
rustc 1.38.0 (625451e37 2019-09-23)
Affected Version of clap
2.33.0 and 3.0.0-beta.1 (b881913)
Expected Behavior Summary
When a global option that takes a value is used both before and after a subcommand, I would expect that
values_of
would return all the values.Actual Behavior Summary
It only returns the values from the subcommand. Flags before the subcommand are ignored.
Note: For global flags that do not take a value,
occurrences_of
correctly returns the count of all occurrences both before and after.Sample Code or Link to Sample Code
Debug output
Debug Output
The text was updated successfully, but these errors were encountered: