Skip to content

Commit

Permalink
test(parser): Reproduce suggestion
Browse files Browse the repository at this point in the history
  • Loading branch information
epage committed Jul 21, 2023
1 parent 55923ca commit 76b891d
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/builder/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,26 @@ For more information, try '--help'.
";
assert_error(err, expected_kind, MESSAGE, true);
}

#[test]
#[cfg(feature = "error-context")]
#[cfg(feature = "suggestions")]
fn cant_use_trailing_subcommand() {
let cmd = Command::new("test").subcommand(Command::new("bar"));

let res = cmd.try_get_matches_from(["test", "baz"]);
assert!(res.is_err());
let err = res.unwrap_err();
let expected_kind = ErrorKind::InvalidSubcommand;
static MESSAGE: &str = "\
error: unrecognized subcommand 'baz'
tip: a similar subcommand exists: 'bar'
tip: to pass 'baz' as a value, use 'test -- baz'
Usage: test [COMMAND]
For more information, try '--help'.
";
assert_error(err, expected_kind, MESSAGE, true);
}

0 comments on commit 76b891d

Please sign in to comment.