From 90e7b0818741668b47cbe3becd029bab588e3553 Mon Sep 17 00:00:00 2001 From: Kevin K Date: Tue, 5 May 2015 18:53:09 -0400 Subject: [PATCH] fix(Positional): positionals were ignored if they matched a subcmd, even after '--' --- src/app.rs | 17 ++--------------- 1 file changed, 2 insertions(+), 15 deletions(-) diff --git a/src/app.rs b/src/app.rs index 4a83252a8a7..fab66bf3e13 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1238,7 +1238,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ I: IntoIterator { match did_you_mean(arg, values) { Some(candidate) => { - let mut suffix = "\n\tDid you mean ".to_owned(); + let mut suffix = "\n\tDid you mean ".to_string(); match style { DidYouMeanMessageStyle::LongFlag => suffix.push_str("--"), DidYouMeanMessageStyle::EnumValue => suffix.push('\''), @@ -1368,7 +1368,6 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ needs_val_of = self.parse_short_arg(matches, &arg); } else { // Positional or Subcommand - // If the user pased `--` we don't check for subcommands, because the argument they // may be trying to pass might match a subcommand name if !pos_only { @@ -1836,7 +1835,7 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ return None; } - let mut suffix = App::did_you_mean_suffix(arg, self.opts.values() + let suffix = App::did_you_mean_suffix(arg, self.opts.values() .filter_map(|v| if let Some(ref l) = v.long { Some(l) @@ -1844,18 +1843,6 @@ 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,