Skip to content

Commit

Permalink
test(parser): Check subcommands conflict with positionals
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jan 11, 2024
1 parent 70da3a8 commit 06bff1c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/builder/conflicts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,26 @@ For more information, try '--help'.
utils::assert_output(cmd, "test --place id sub1", CONFLICT_ERR, true);
}

#[test]
#[cfg(feature = "error-context")]
fn positional_conflicts_with_subcommand() {
static CONFLICT_ERR: &str = "\
error: unexpected argument 'sub1' found
Usage: test <arg1>
test <COMMAND>
For more information, try '--help'.
";

let cmd = Command::new("test")
.args_conflicts_with_subcommands(true)
.arg(arg!(<arg1> "some arg"))
.subcommand(Command::new("sub1"));

utils::assert_output(cmd, "test value1 sub1", CONFLICT_ERR, true);
}

#[test]
fn subcommand_conflict_negates_required() {
let cmd = Command::new("test")
Expand Down

0 comments on commit 06bff1c

Please sign in to comment.