Skip to content

Commit

Permalink
fix(Suggestions): output for flag after subcommand
Browse files Browse the repository at this point in the history
  • Loading branch information
wabain committed Aug 5, 2017
1 parent 1ef6e62 commit 434ea5b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
7 changes: 4 additions & 3 deletions src/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
}
}
Expand Down
6 changes: 3 additions & 3 deletions tests/subcommands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 434ea5b

Please sign in to comment.