mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 15:27:16 +00:00
test(parser): Show flag behavior
This commit is contained in:
parent
06bff1c955
commit
e2b18f199f
1 changed files with 24 additions and 0 deletions
|
@ -724,6 +724,30 @@ For more information, try '--help'.
|
|||
utils::assert_output(cmd, "test value1 sub1", CONFLICT_ERR, true);
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "error-context")]
|
||||
fn flag_conflicts_with_subcommand_long_flag() {
|
||||
let cmd = Command::new("test")
|
||||
.args_conflicts_with_subcommands(true)
|
||||
.arg(arg!(--hello))
|
||||
.subcommand(Command::new("sub").long_flag("sub"));
|
||||
|
||||
let res = cmd.try_get_matches_from(vec!["", "--hello", "--sub"]);
|
||||
assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind());
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(feature = "error-context")]
|
||||
fn flag_conflicts_with_subcommand_short_flag() {
|
||||
let cmd = Command::new("test")
|
||||
.args_conflicts_with_subcommands(true)
|
||||
.arg(arg!(--hello))
|
||||
.subcommand(Command::new("sub").short_flag('s'));
|
||||
|
||||
let res = cmd.try_get_matches_from(vec!["", "--hello", "-s"]);
|
||||
assert!(res.is_ok(), "error: {:?}", res.unwrap_err().kind());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn subcommand_conflict_negates_required() {
|
||||
let cmd = Command::new("test")
|
||||
|
|
Loading…
Add table
Reference in a new issue