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()));
            }
            // 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 argument.user_value.is_some() {
                if let Some(arg_name) = argument.requires {
                    if !args.contains(&(format!("--{}", arg_name))) {
                        return Err(Error::MissingArgument(arg_name.to_string()));
                    }
                }
            }
        }
        Ok(())
    }
// Check if `required` and `requires` field rules are indeed followed by every argument.
Check if `required` and `requires` field rules are indeed followed by every argument.
Check if ` required ` and ` requires ` field rules are indeed followed by every argument .
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()));
            }
            // 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 argument.user_value.is_some() {
                if let Some(arg_name) = argument.requires {
                    if !args.contains(&(format!("--{}", arg_name))) {
                        return Err(Error::MissingArgument(arg_name.to_string()));
                    }
                }
            }
        }
        Ok(())
    }
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 ( ) ) ) ; } // 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 argument . user_value . is_some ( ) { if let Some ( arg_name ) = argument . requires { if ! args . contains ( & ( format ! ( " " arg_name ) ) ) { return Err ( Error :: MissingArgument ( arg_name . to_string ( ) ) ) ; } } } } Ok ( ( ) ) }
Check if `required` and `requires` field rules are indeed followed by every argument.
Check if ` required ` and ` requires ` field rules are indeed followed by every argument .
&self
args
&[String]