diff --git a/src/app.rs b/src/app.rs index fab66bf3e13..f1487e6019d 100644 --- a/src/app.rs +++ b/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,