Skip to content

Commit

Permalink
fix(RequiredValues): fixes a bug where missing values are parsed as m…
Browse files Browse the repository at this point in the history
…issing arguments
  • Loading branch information
kbknapp committed May 3, 2015
1 parent 80352bf commit 93c4a72
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Vec<_>>() ) );
}
else {
self.report_error(format!("The following required arguments were not \
supplied:\n{}",
Expand All @@ -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::<Vec<_>>()));
Expand Down

0 comments on commit 93c4a72

Please sign in to comment.