Replicate the derive test for from_global

This commit is contained in:
Felipe Sere 2021-05-18 22:21:18 +01:00
parent 856de610a2
commit 03d4989ef9

View file

@ -82,3 +82,18 @@ fn propagate_global_arg_to_subcommand_in_subsubcommand_2053() {
m.subcommand_matches("test").unwrap().value_of("sub-str")
);
}
#[test]
fn global_arg_available_in_subcommand() {
let m = App::new("opt")
.args(&[
Arg::new("global").global(true).long("global"),
Arg::new("not").global(false).long("not"),
])
.subcommand(App::new("ping"))
.get_matches_from(&["opt", "ping", "--global"]);
assert!(m.is_present("global"));
assert!(m.subcommand_matches("ping").unwrap().is_present("global"));
assert!(!m.subcommand_matches("ping").unwrap().is_present("not"));
}