in src/utils/src/arg_parser.rs [388:414]
fn validate_requirements(&self, args: &[String]) -> Result<()> {
for argument in self.args.values() {
// The arguments that are marked `required` must be provided by user.
if argument.required && argument.user_value.is_none() {
return Err(Error::MissingArgument(argument.name.to_string()));
}
if argument.user_value.is_some() {
// For the arguments that require a specific argument to be also present in the list
// of arguments provided by user, search for that argument.
if let Some(arg_name) = argument.requires {
if !args.contains(&(format!("--{}", arg_name))) {
return Err(Error::MissingArgument(arg_name.to_string()));
}
}
// Check the user-provided list for potential forbidden arguments.
for arg_name in argument.forbids.iter() {
if args.contains(&(format!("--{}", arg_name))) {
return Err(Error::ForbiddenArgument(
argument.name.to_string(),
arg_name.to_string(),
));
}
}
}
}
Ok(())
}