fn interpolate_env_vars(cmd_str: &str, env_vars: &[String]) -> Result<String, String> {
        let mut with_env_vars = cmd_str.to_string();
        for env_var_name in env_vars.iter() {
            // Load the environment variable
            let env_var = env::var(env_var_name);
            let env_var = match env_var {
                Ok(env_var) => env_var,
                Err(_) => return Err(format!("The environment variable '{}' couldn't be loaded. This means it either hasn't been defined (you may need to load another environment variable file) or contains invalid characters.", env_var_name))
            };
            // Interpolate it into the command itself
            let to_replace = "%".to_string() + env_var_name;
            let new_command = with_env_vars.replace(&to_replace, &env_var);
            // We don't check if we changed something because that doesn't work for multistage or ordered subcommands
            with_env_vars = new_command;
        }

        Ok(with_env_vars)
    }
// Interpolates environment variables
// This takes a string to interpolate into, the environment variables to interpolate, and the name of the command
// This doesn't take `self` so the order is open
// This returns the readied command string only, or an error relating to environment variable loading
Interpolates environment variables
This takes a string to interpolate into, the environment variables to interpolate, and the name of the command
This doesn't take `self` so the order is open
This returns the readied command string only, or an error relating to environment variable loading
Interpolates environment variables This takes a string to interpolate into the environment variables to interpolate and the name of the command This doesn ' t take ` self ` so the order is open This returns the readied command string only or an error relating to environment variable loading
fn interpolate_env_vars(cmd_str: &str, env_vars: &[String]) -> Result<String, String> {
        let mut with_env_vars = cmd_str.to_string();
        for env_var_name in env_vars.iter() {
            // Load the environment variable
            let env_var = env::var(env_var_name);
            let env_var = match env_var {
                Ok(env_var) => env_var,
                Err(_) => return Err(format!("The environment variable '{}' couldn't be loaded. This means it either hasn't been defined (you may need to load another environment variable file) or contains invalid characters.", env_var_name))
            };
            // Interpolate it into the command itself
            let to_replace = "%".to_string() + env_var_name;
            let new_command = with_env_vars.replace(&to_replace, &env_var);
            // We don't check if we changed something because that doesn't work for multistage or ordered subcommands
            with_env_vars = new_command;
        }
        Ok(with_env_vars)
    }
fn interpolate_env_vars ( cmd_str : & str , env_vars : & [ String ] ) -> Result < String , String > { let mut with_env_vars = cmd_str . to_string ( ) ; for env_var_name in env_vars . iter ( ) { // Load the environment variable let env_var = env :: var ( env_var_name ) ; let env_var = match env_var { Ok ( env_var ) => env_var , Err ( _ ) => return Err ( format ! ( " " env_var_name ) ) } ; // Interpolate it into the command itself let to_replace = " " . to_string ( ) + env_var_name ; let new_command = with_env_vars . replace ( & to_replace , & env_var ) ; // We don't check if we changed something because that doesn't work for multistage or ordered subcommands with_env_vars = new_command ; } Ok ( with_env_vars ) }
Interpolates environment variables
This takes a string to interpolate into, the environment variables to interpolate, and the name of the command
This doesn't take `self` so the order is open
This returns the readied command string only, or an error relating to environment variable loading
Interpolates environment variables This takes a string to interpolate into the environment variables to interpolate and the name of the command This doesn ' t take ` self ` so the order is open This returns the readied command string only or an error relating to environment variable loading
cmd_str
&str
env_vars
&[String]