mirror of
https://github.com/clap-rs/clap
synced 2025-03-04 15:27:16 +00:00
perf(validate): Remove unnecesarry walking of args
This commit is contained in:
parent
f9bb3de750
commit
9824f8d0ba
1 changed files with 9 additions and 10 deletions
|
@ -54,16 +54,15 @@ impl<'help, 'app, 'parser> Validator<'help, 'app, 'parser> {
|
|||
}
|
||||
}
|
||||
|
||||
let num_user_values = matcher
|
||||
.arg_names()
|
||||
.filter(|arg_id| matcher.check_explicit(arg_id, ArgPredicate::IsPresent))
|
||||
.count();
|
||||
if num_user_values == 0
|
||||
&& matcher.subcommand_name().is_none()
|
||||
&& self.p.app.is_arg_required_else_help_set()
|
||||
{
|
||||
let message = self.p.write_help_err()?;
|
||||
return Err(Error::display_help_error(self.p.app, message));
|
||||
if matcher.subcommand_name().is_none() && self.p.app.is_arg_required_else_help_set() {
|
||||
let num_user_values = matcher
|
||||
.arg_names()
|
||||
.filter(|arg_id| matcher.check_explicit(arg_id, ArgPredicate::IsPresent))
|
||||
.count();
|
||||
if num_user_values == 0 {
|
||||
let message = self.p.write_help_err()?;
|
||||
return Err(Error::display_help_error(self.p.app, message));
|
||||
}
|
||||
}
|
||||
self.validate_conflicts(matcher)?;
|
||||
if !(self.p.app.is_subcommand_negates_reqs_set() && is_subcmd || reqs_validated) {
|
||||
|
|
Loading…
Add table
Reference in a new issue