Skip to content

Commit

Permalink
test(parser): Show flag behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 11, 2024
1 parent 06bff1c commit e2b18f1
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/builder/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down

0 comments on commit e2b18f1

Please sign in to comment.