mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 14:52:33 +00:00
Merge pull request #1019 from wabain/fix-flag-after-subcommand-suggestion
Fix suggestions for flags under subcommands
This commit is contained in:
commit
05aec692cb
2 changed files with 7 additions and 6 deletions
|
@ -58,9 +58,10 @@ pub fn did_you_mean_flag_suffix<'z, T, I>(arg: &str, longs: I, subcommands: &'z
|
|||
|
||||
if let Some(candidate) = did_you_mean(arg, opts) {
|
||||
let suffix = format!(
|
||||
"\n\tDid you mean to put '--{}' after the subcommand '{}'?",
|
||||
Format::Good(arg),
|
||||
Format::Good(candidate));
|
||||
"\n\tDid you mean to put '{}{}' after the subcommand '{}'?",
|
||||
Format::Good("--"),
|
||||
Format::Good(candidate),
|
||||
Format::Good(subcommand.get_name()));
|
||||
return (suffix, Some(candidate));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,8 +43,8 @@ USAGE:
|
|||
For more information try --help";
|
||||
|
||||
#[cfg(feature = "suggestions")]
|
||||
static DYM2: &'static str = "error: Found argument '--subcmdarg' which wasn't expected, or isn't valid in this context
|
||||
\tDid you mean to put '--subcmdarg' after the subcommand 'subcmdarg'?
|
||||
static DYM2: &'static str = "error: Found argument '--subcm' which wasn't expected, or isn't valid in this context
|
||||
\tDid you mean to put '--subcmdarg' after the subcommand 'subcmd'?
|
||||
|
||||
USAGE:
|
||||
clap-test [FLAGS] [OPTIONS] [ARGS] [SUBCOMMAND]
|
||||
|
@ -130,7 +130,7 @@ fn multiple_aliases() {
|
|||
#[cfg(feature="suggestions")]
|
||||
fn subcmd_did_you_mean_output() {
|
||||
assert!(test::compare_output(test::complex_app(), "clap-test subcm", DYM, true));
|
||||
assert!(test::compare_output(test::complex_app(), "clap-test --subcmdarg foo", DYM2, true));
|
||||
assert!(test::compare_output(test::complex_app(), "clap-test --subcm foo", DYM2, true));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue