feat(Flags): adds sugestions functionality

This commit is contained in:
Kevin K 2015-05-05 19:37:27 -04:00
parent 0eda91a447
commit 8745071c32

View file

@ -1835,7 +1835,7 @@ 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)
@ -1843,6 +1843,18 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
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,