Skip to content

Commit

Permalink
refactor(help): Remove redundant required check
Browse files Browse the repository at this point in the history
With us moving the required de-duplication up a level, it made this
check redundant.  By removing this check, we're more likely to have an
item in the `incls` which forces a smart usage and reduces the chance of
an `[ARGS]` or `[OPTIONS]`, so a couple of tests changed.
  • Loading branch information
epage committed May 5, 2022
1 parent f7c2dea commit e23c786
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/parse/validator.rs
Expand Up @@ -601,9 +601,7 @@ impl<'help, 'cmd> Validator<'help, 'cmd> {
.filter(|arg_id| matcher.check_explicit(arg_id, ArgPredicate::IsPresent))
.filter(|n| {
// Filter out the args we don't want to specify.
self.cmd
.find(n)
.map_or(true, |a| !a.is_hide_set() && !self.required.contains(&a.id))
self.cmd.find(n).map_or(true, |a| !a.is_hide_set())
})
.cloned()
.chain(incl)
Expand Down
4 changes: 2 additions & 2 deletions tests/builder/double_require.rs
Expand Up @@ -16,7 +16,7 @@ static ONLY_B_ERROR: &str = "error: The following required arguments were not pr
-c
USAGE:
prog [OPTIONS] -b -c
prog -b -c
For more information try --help
";
Expand All @@ -25,7 +25,7 @@ static ONLY_C_ERROR: &str = "error: The following required arguments were not pr
-b
USAGE:
prog [OPTIONS] -c -b
prog -c -b
For more information try --help
";
Expand Down
2 changes: 1 addition & 1 deletion tests/builder/require.rs
Expand Up @@ -170,7 +170,7 @@ static POSITIONAL_REQ_IF_VAL: &str = "error: The following required arguments we
<opt>
USAGE:
clap-test <flag> <foo> <opt> [ARGS]
clap-test <flag> <foo> <opt>
For more information try --help
";
Expand Down

0 comments on commit e23c786

Please sign in to comment.