mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
tests: adds tests for propogating values down
This commit is contained in:
parent
985536c8eb
commit
c142fb544d
1 changed files with 13 additions and 0 deletions
|
@ -450,3 +450,16 @@ fn args_negate_subcommands_two_levels() {
|
||||||
let m = res.unwrap();
|
let m = res.unwrap();
|
||||||
assert_eq!(m.subcommand_matches("sub1").unwrap().value_of("arg2"), Some("sub2"));
|
assert_eq!(m.subcommand_matches("sub1").unwrap().value_of("arg2"), Some("sub2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn propagate_vals_down() {
|
||||||
|
let m = App::new("myprog")
|
||||||
|
.setting(AppSettings::PropagateGlobalValuesDown)
|
||||||
|
.arg(Arg::from_usage("[cmd] 'command to run'").global(true))
|
||||||
|
.subcommand(SubCommand::with_name("foo"))
|
||||||
|
.get_matches_from(vec!["myprog", "set", "foo"]);
|
||||||
|
assert_eq!(m.value_of("cmd"), Some("set"));
|
||||||
|
let sub_m = m.subcommand_matches("foo").unwrap();
|
||||||
|
assert_eq!(sub_m.value_of("cmd"), Some("set"));
|
||||||
|
}
|
Loading…
Reference in a new issue