From 93c4a7231ba1a08152648598f7aa4503ea82e4de Mon Sep 17 00:00:00 2001 From: Kevin K Date: Sun, 3 May 2015 15:39:49 -0400 Subject: [PATCH] fix(RequiredValues): fixes a bug where missing values are parsed as missing arguments --- src/app.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/app.rs b/src/app.rs index ed7abf79..3e8cc248 100644 --- a/src/app.rs +++ b/src/app.rs @@ -1356,6 +1356,13 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ Some(ref a) => { if let Some(o) = self.opts.get(a) { if o.multiple && self.required.is_empty() { () } + else if !o.multiple { + self.report_error( + format!("Argument {} requires a value but none was supplied", o), + true, + true, + Some(matches.args.keys().map(|k| *k).collect::>() ) ); + } else { self.report_error(format!("The following required arguments were not \ supplied:\n{}", @@ -1371,14 +1378,8 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{ } else { self.report_error( format!("Argument {} requires a value but none was supplied", - if let Some(f) = self.flags.get(a) { - format!("{}", f) - } else if let Some(o) = self.opts.get(a) { - format!("{}", o) - } else { - format!("{}", self.positionals_idx.get( - self.positionals_name.get(a).unwrap()).unwrap()) - }), + format!("{}", self.positionals_idx.get( + self.positionals_name.get(a).unwrap()).unwrap())), true, true, Some(matches.args.keys().map(|k| *k).collect::>()));