mirror of
https://github.com/clap-rs/clap
synced 2024-11-10 14:54:15 +00:00
fix: ArgRequiredElseHelp setting now takes precedence over missing required args
Closes #362
This commit is contained in:
parent
27872270db
commit
faad83fbef
1 changed files with 7 additions and 2 deletions
|
@ -2728,12 +2728,17 @@ impl<'a, 'v, 'ab, 'u, 'h, 'ar> App<'a, 'v, 'ab, 'u, 'h, 'ar> {
|
|||
if let Some(a) = self.positionals.values().filter(|p| &p.name == name).next() {
|
||||
if self._validate_blacklist_required(a, matcher) { continue 'outer; }
|
||||
}
|
||||
return Err(error_builder::MissingRequiredArgument(
|
||||
let err = if self.settings.is_set(&AppSettings::ArgRequiredElseHelp) && matcher.is_empty() {
|
||||
self._help().unwrap_err()
|
||||
} else {
|
||||
error_builder::MissingRequiredArgument(
|
||||
&*self.get_required_from(&self.required, Some(matcher))
|
||||
.iter()
|
||||
.fold(String::new(),
|
||||
|acc, s| acc + &format!("\n\t{}", Format::Error(s))[..]),
|
||||
&*try!(self.create_current_usage(matcher))));
|
||||
&*try!(self.create_current_usage(matcher)))
|
||||
};
|
||||
return Err(err);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue