From 06bff1c95503536953cb6ddb308f52d15b6afe57 Mon Sep 17 00:00:00 2001 From: Ed Page Date: Thu, 11 Jan 2024 08:48:23 -0600 Subject: [PATCH] test(parser): Check subcommands conflict with positionals --- tests/builder/conflicts.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/builder/conflicts.rs b/tests/builder/conflicts.rs index d623f8c9508..77f9d5cae17 100644 --- a/tests/builder/conflicts.rs +++ b/tests/builder/conflicts.rs @@ -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 + test + +For more information, try '--help'. +"; + + let cmd = Command::new("test") + .args_conflicts_with_subcommands(true) + .arg(arg!( "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")