Skip to content

Commit

Permalink
feat(Flags): adds sugestions functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 6, 2015
1 parent 0eda91a commit 8745071
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app.rs
Expand Up @@ -1835,14 +1835,26 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
return None;
}

let suffix = App::did_you_mean_suffix(arg, self.opts.values()
let mut suffix = App::did_you_mean_suffix(arg, self.opts.values()
.filter_map(|v|
if let Some(ref l) = v.long {
Some(l)
} else {
None
}
), DidYouMeanMessageStyle::LongFlag);

// If it didn't find a good match for opts, try flags
if suffix.is_empty() {
suffix = App::did_you_mean_suffix(arg, self.flags.values()
.filter_map(|v|
if let Some(ref l) = v.long {
Some(l)
} else {
None
}
), DidYouMeanMessageStyle::LongFlag);
}
self.report_error(format!("The argument --{} isn't valid{}", arg, suffix),
true,
true,
Expand Down

0 comments on commit 8745071

Please sign in to comment.