test(parser): Show flag behavior

This commit is contained in:
Ed Page 2024-01-10 20:14:59 -06:00
parent 06bff1c955
commit e2b18f199f

View file

@ -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")