Skip to content

Commit

Permalink
fix(help): allows parent requirements to be ignored with help and ver…
Browse files Browse the repository at this point in the history
…sion

Parent requirements are now ignored when the user requests help or
version switches

Closes #124
  • Loading branch information
kbknapp committed May 20, 2015
1 parent 4708687 commit 52218cc
Showing 1 changed file with 14 additions and 14 deletions.
28 changes: 14 additions & 14 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1639,20 +1639,6 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
self.validate_blacklist(matches);
self.validate_num_args(matches);

if !self.required.is_empty() && !self.subcmds_neg_reqs {
if self.validate_required(&matches) {
self.report_error(format!("The following required arguments were not \
supplied:{}",
self.get_required_from(self.required.iter()
.map(|s| *s)
.collect::<Vec<_>>())
.iter()
.fold(String::new(), |acc, s| acc + &format!("\n\t'{}'",s)[..])),
true,
true,
Some(matches.args.keys().map(|k| *k).collect()));
}
}

matches.usage = Some(self.create_usage(None));

Expand Down Expand Up @@ -1703,6 +1689,20 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar>{
'help'", &bn[..]);
self.exit(1);
}
if !self.required.is_empty() && !self.subcmds_neg_reqs {
if self.validate_required(&matches) {
self.report_error(format!("The following required arguments were not \
supplied:{}",
self.get_required_from(self.required.iter()
.map(|s| *s)
.collect::<Vec<_>>())
.iter()
.fold(String::new(), |acc, s| acc + &format!("\n\t'{}'",s)[..])),
true,
true,
Some(matches.args.keys().map(|k| *k).collect()));
}
}
}

fn blacklisted_from(&self, name: &str, matches: &ArgMatches) -> Option<String> {
Expand Down

0 comments on commit 52218cc

Please sign in to comment.