mirror of
https://github.com/clap-rs/clap
synced 2024-09-20 14:31:58 +00:00
test(parser): Reproduce suggestion
This commit is contained in:
parent
55923ca947
commit
76b891db41
1 changed files with 23 additions and 0 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue