Skip to content

Commit

Permalink
fix(Options): fixes bug where options with no value don't error out
Browse files Browse the repository at this point in the history
  • Loading branch information
kbknapp committed May 4, 2015
1 parent 37a925d commit a1fb94b
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1401,7 +1401,19 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
match needs_val_of {
Some(ref a) => {
if let Some(o) = self.opts.get(a) {
if o.multiple && self.required.is_empty() { () }
if o.multiple && self.required.is_empty() {
let should_err = match matches.values_of(o.name) {
Some(ref v) => if v.len() == 0 { true } else { false },
None => true,
};
if should_err {
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 if !o.multiple {
self.report_error(
format!("Argument '{}' requires a value but none was supplied", o),
Expand Down

0 comments on commit a1fb94b

Please sign in to comment.