Skip to content

Commit

Permalink
fix(Usage): fixes a bug where required args aren't filtered properly
Browse files Browse the repository at this point in the history
Closes #277
  • Loading branch information
kbknapp committed Oct 3, 2015
1 parent 0e3733e commit 72b453d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/app/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3272,13 +3272,28 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
return Err(self.report_error(format!("The argument '{}' isn't valid",
Format::Warning(format!("-{}", c))),
ClapErrorType::InvalidArgument,
Some(matches.args.keys().map(|k| *k).collect())));
Some(matches.args.keys()
.map(|k| *k)
.filter(|k| {
if let Some(o) = self.opts.get(k) {
!o.settings.is_set(&ArgSettings::Required)
} else if let Some(p) = self.positionals_name.get(k) {
if let Some(p) = self.positionals_idx.get(p) {
!p.settings.is_set(&ArgSettings::Required)
} else {
true
}
} else {
true
}
})
.collect())));
}
}
Err(e) => return Err(e),
}
}
unreachable!();
return Ok(None);
}

fn parse_single_short_flag(&mut self,
Expand Down

0 comments on commit 72b453d

Please sign in to comment.