mirror of
https://github.com/clap-rs/clap
synced 2024-12-13 14:22:34 +00:00
fix(parser): Override required when parent group has conflict
Fixes #4569
This commit is contained in:
parent
d145b8b166
commit
85ecb3e895
2 changed files with 14 additions and 3 deletions
|
@ -371,8 +371,17 @@ impl<'cmd> Validator<'cmd> {
|
|||
|
||||
fn is_missing_required_ok(&self, a: &Arg, conflicts: &Conflicts) -> bool {
|
||||
debug!("Validator::is_missing_required_ok: {}", a.get_id());
|
||||
let conflicts = conflicts.gather_conflicts(self.cmd, a.get_id());
|
||||
!conflicts.is_empty()
|
||||
if !conflicts.gather_conflicts(self.cmd, a.get_id()).is_empty() {
|
||||
debug!("Validator::is_missing_required_ok: true (self)");
|
||||
return true;
|
||||
}
|
||||
for group_id in self.cmd.groups_for_arg(a.get_id()) {
|
||||
if !conflicts.gather_conflicts(self.cmd, &group_id).is_empty() {
|
||||
debug!("Validator::is_missing_required_ok: true ({})", group_id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
// Failing a required unless means, the arg's "unless" wasn't present, and neither were they
|
||||
|
|
|
@ -259,7 +259,9 @@ fn arg_conflicts_with_group_with_required_memeber() {
|
|||
}
|
||||
|
||||
let result = cmd.try_get_matches_from_mut(vec!["myprog", "--flag"]);
|
||||
assert!(result.is_err());
|
||||
if let Err(err) = result {
|
||||
panic!("{}", err);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
Loading…
Reference in a new issue