Skip to content

Commit

Permalink
Merge pull request #3696 from epage/usage
Browse files Browse the repository at this point in the history
refactor(help): Remove more redundant required checks
  • Loading branch information
epage authored May 6, 2022
2 parents dcda237 + 05aecf8 commit 0e1e952
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 10 deletions.
6 changes: 1 addition & 5 deletions src/parse/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1468,11 +1468,7 @@ impl<'help, 'cmd> Parser<'help, 'cmd> {
let required = self.cmd.required_graph();
let used: Vec<Id> = matcher
.arg_names()
.filter(|n| {
self.cmd
.find(n)
.map_or(true, |a| !(required.contains(&a.id) || a.is_hide_set()))
})
.filter(|n| self.cmd.find(n).map_or(true, |a| !a.is_hide_set()))
.cloned()
.collect();

Expand Down
6 changes: 1 addition & 5 deletions src/parse/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,7 @@ impl<'help, 'cmd> Validator<'help, 'cmd> {
let used: Vec<Id> = matcher
.arg_names()
.filter(|arg_id| matcher.check_explicit(arg_id, ArgPredicate::IsPresent))
.filter(|&n| {
self.cmd.find(n).map_or(true, |a| {
!(a.is_hide_set() || self.required.contains(&a.id))
})
})
.filter(|&n| self.cmd.find(n).map_or(true, |a| !a.is_hide_set()))
.cloned()
.collect();
return Err(Error::invalid_value(
Expand Down

0 comments on commit 0e1e952

Please sign in to comment.