You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Jan 1, 2022. It is now read-only.
2.33.0 and 3.0.0-beta.1 (b8819130de876c4abbd451c34df89161a98d23ef)
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
use clap::{App,Arg};fnmain(){let matches = App::new("myapp").arg(Arg::with_name("global-opt").short('A').multiple(true).number_of_values(1).global(true),).subcommand(App::new("test")).get_matches_from(vec!["myapp", "-Aone", "test", "-Atwo"]);let gs = matches.values_of("global-opt").unwrap().collect::<Vec<_>>();// I would expect this to be ["one", "two"]assert_eq!(gs, vec!["two"]);}
Comment by yaahc Tuesday Feb 04, 2020 at 23:56 GMT
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 ArgMatches.subcommand() matches properly
Issue by ehuss
Tuesday Oct 08, 2019 at 18:28 GMT
Originally opened as clap-rs/clap#1570
Rust Version
rustc 1.38.0 (625451e37 2019-09-23)
Affected Version of clap
2.33.0 and 3.0.0-beta.1 (b8819130de876c4abbd451c34df89161a98d23ef)
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: