mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 22:32:33 +00:00
feat(Flags): adds sugestions functionality
This commit is contained in:
parent
0eda91a447
commit
8745071c32
1 changed files with 13 additions and 1 deletions
14
src/app.rs
14
src/app.rs
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue