Commit bda9ea80 authored by Wohlgemuth, Jason's avatar Wohlgemuth, Jason
Browse files

feat: Add input CLI arg

parent b5d3674e
Loading
Loading
Loading
Loading
Loading
+57 −50
Original line number Diff line number Diff line
@@ -112,43 +112,47 @@ FN:16,run
FNF:1
FNDA:0,run
DA:16,0
DA:26,0
DA:27,0
DA:28,0
DA:30,0
DA:29,0
DA:31,0
DA:33,0
DA:35,0
DA:32,0
DA:34,0
DA:36,0
DA:37,0
DA:39,0
DA:38,0
DA:40,0
DA:42,0
DA:41,0
DA:43,0
DA:44,0
DA:47,0
DA:45,0
DA:48,0
DA:49,0
DA:50,0
DA:57,0
DA:51,0
DA:58,0
DA:59,0
DA:60,0
DA:61,0
DA:63,0
DA:62,0
DA:64,0
DA:71,0
DA:65,0
DA:72,0
DA:73,0
DA:78,0
DA:74,0
DA:79,0
DA:80,0
DA:81,0
DA:82,0
DA:84,0
DA:85,0
DA:89,0
DA:86,0
DA:87,0
DA:90,0
DA:91,0
LF:37
DA:96,0
DA:98,0
LF:41
LH:0
end_of_record
TN:
@@ -169,12 +173,12 @@ DA:56,0
DA:57,0
DA:68,0
DA:69,0
DA:83,0
DA:84,0
DA:85,0
DA:86,0
DA:87,0
DA:88,0
DA:89,0
DA:91,0
LF:19
LH:0
end_of_record
@@ -288,7 +292,7 @@ FNDA:0,Config::get_environment_variables
FNDA:1,Config::get_inputs
FNDA:1,Config::get_module_list
FNDA:0,Config::prepare_modules
FNDA:1,Config::read
FNDA:3,Config::read
FNDA:1,Config::read_json
FNDA:1,Config::read_yaml
FNDA:0,Config::run_workflow
@@ -296,17 +300,20 @@ FNDA:0,Config::set_environment_variables
FNDA:0,Config::verify_requirements
FNDA:0,Config::verify_resources
FNDA:0,Config::with_options
FNDA:2,Extension::from_string
FNDA:3,Extension::from_string
DA:119,0
DA:120,0
DA:121,0
DA:122,0
DA:123,0
DA:124,0
DA:125,0
DA:126,0
DA:127,0
DA:128,0
DA:129,0
DA:130,0
DA:131,0
DA:132,0
DA:133,0
DA:139,1
DA:140,1
DA:141,1
@@ -442,29 +449,29 @@ DA:400,0
DA:402,0
DA:404,0
DA:406,0
DA:408,1
DA:409,3
DA:410,3
DA:411,1
DA:408,3
DA:409,6
DA:410,6
DA:411,3
DA:412,0
DA:414,2
DA:415,1
DA:416,0
DA:420,3
DA:421,2
DA:420,6
DA:421,3
DA:423,0
DA:424,0
DA:432,1
DA:433,2
DA:434,4
DA:434,2
DA:436,0
DA:437,0
DA:440,4
DA:441,2
DA:442,4
DA:440,5
DA:441,4
DA:442,8
DA:443,0
DA:445,6
DA:446,2
DA:445,12
DA:446,4
DA:453,1
DA:454,2
DA:455,1
@@ -551,12 +558,12 @@ DA:602,0
DA:604,0
DA:605,0
DA:606,0
DA:610,2
DA:611,3
DA:612,3
DA:610,3
DA:611,6
DA:612,6
DA:613,3
DA:614,0
LF:259
LF:262
LH:42
end_of_record
TN:
@@ -859,8 +866,8 @@ DA:665,1
DA:666,0
DA:668,0
DA:669,0
DA:672,2
DA:673,1
DA:672,4
DA:673,2
DA:675,1
DA:677,1
DA:678,1
@@ -964,7 +971,7 @@ DA:841,0
DA:842,0
DA:843,0
DA:886,1
DA:887,2
DA:887,1
DA:888,1
DA:892,1
DA:893,2
@@ -1006,7 +1013,7 @@ DA:982,0
DA:984,0
DA:1013,1
DA:1014,2
DA:1015,1
DA:1015,2
DA:1016,0
DA:1018,3
DA:1019,1
@@ -1061,8 +1068,8 @@ FNDA:0,Label::pass
FNDA:0,Label::read
FNDA:0,Label::rejected
FNDA:0,Label::run
FNDA:2,Label::using
FNDA:2,Label::fmt_using
FNDA:4,Label::using
FNDA:4,Label::fmt_using
FNDA:1,add_dot_slash
FNDA:1,add_forward_slash
FNDA:0,download_binary
@@ -1106,11 +1113,11 @@ DA:71,0
DA:73,0
DA:74,0
DA:75,0
DA:77,2
DA:78,2
DA:80,2
DA:81,2
DA:82,2
DA:77,4
DA:78,4
DA:80,4
DA:81,4
DA:82,4
DA:86,1
DA:87,2
DA:88,2
@@ -1149,8 +1156,8 @@ DA:184,1
DA:185,1
DA:186,4
DA:187,2
DA:202,2
DA:203,1
DA:202,3
DA:203,3
DA:206,1
DA:207,3
DA:219,1
@@ -1175,12 +1182,12 @@ DA:268,2
DA:269,2
DA:270,4
DA:271,3
DA:272,10
DA:272,9
DA:273,6
DA:275,1
DA:276,3
DA:277,1
DA:280,2
DA:280,1
DA:282,1
DA:283,3
DA:285,1
+17 −14
Original line number Diff line number Diff line
@@ -35,25 +35,25 @@ pub enum Commands {
        #[arg(value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        path: Option<std::path::PathBuf>,
        /// Path to configuration file
        #[arg(short = 'c', long = "config", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        #[arg(short, long, value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        config: Option<std::path::PathBuf>,
        /// Reporter(s) to use to output the results - console (default) and/or json
        #[arg(short = 'r', long = "reporter", value_name = "STRING", num_args=0..=2)]
        #[arg(short, long, value_name = "STRING", num_args=0..=2)]
        reporter: Option<Vec<String>>,
        /// Destination path for reporters that use one
        #[arg(short = 'o', long = "output", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        #[arg(short, long, value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        output: Option<std::path::PathBuf>,
        /// Return all results that pass or fail check conditions
        #[arg(short = 'a', long = "all", value_name = "BOOL")]
        #[arg(short, long, value_name = "BOOL")]
        all: bool,
        /// Only return results that pass their associated check
        #[arg(short = 'p', long = "pass", value_name = "BOOL")]
        #[arg(short, long, value_name = "BOOL")]
        pass: bool,
        /// Report results in minimal format
        #[arg(short = 'm', long = "minimal", value_name = "BOOL")]
        #[arg(short, long, value_name = "BOOL")]
        minimal: bool,
        /// Deduplicate results
        #[arg(short = 'u', long = "unique", value_name = "BOOL")]
        #[arg(short, long, value_name = "BOOL")]
        unique: bool,
    },
    /// Check environment parameters and verify PIPE requirements are met
@@ -67,10 +67,10 @@ pub enum Commands {
        /// Path to configuration file
        ///
        /// Validate PIPE requirements are met for a given configuration
        #[arg(short = 'c', long = "config", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        #[arg(short, long, value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        config: Option<std::path::PathBuf>,
        /// Scan environment and attempt to fix unmet requirements
        #[arg(short = 'f', long = "fix", value_name = "BOOL")]
        #[arg(short, long, value_name = "BOOL")]
        fix: bool,
    },
    /// Run workflow using configuration file
@@ -84,19 +84,22 @@ pub enum Commands {
    #[clap(verbatim_doc_comment)]
    Run {
        /// Path to configuration file
        #[arg(short = 'c', long = "config", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        #[arg(short, long, value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        config: Option<std::path::PathBuf>,
        /// Reporter(s) to use to output the results - console (default) and/or json
        #[arg(short = 'r', long = "reporter", value_name = "STRING", num_args=0..=2)]
        #[arg(short, long, value_name = "STRING", num_args=0..=2)]
        reporter: Option<Vec<String>>,
        /// Destination path for reporters that use one
        #[arg(short = 'o', long = "output", value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        #[arg(short, long, value_name = "PATH", value_hint = clap::ValueHint::DirPath)]
        output: Option<std::path::PathBuf>,
        /// Value(s) to use as INPUT variable in workflow
        #[arg(short, long, value_name = "LIST", value_delimiter = ',')]
        input: Option<Vec<String>>,
        /// Execute workflow dry run (do not actually make changes to environment)
        #[arg(short = 'd', long = "dry-run", value_name = "BOOL")]
        #[arg(short, long = "dry-run", value_name = "BOOL")]
        dry_run: bool,
        /// Execute workflow without connection to the internet
        #[arg(long = "offline", value_name = "BOOL")]
        #[arg(long, value_name = "BOOL")]
        offline: bool,
        /// Skip calculating and verifying checksum for downloaded binary files
        #[arg(long = "skip-verify-checksum", value_name = "BOOL")]
+11 −4
Original line number Diff line number Diff line
@@ -17,6 +17,7 @@ pub fn run(
    config: &Option<PathBuf>,
    _reporter: &Option<Vec<String>>,
    _output: &Option<PathBuf>,
    cli_input: &Option<Vec<String>>,
    cli_dry_run: bool,
    cli_offline: bool,
    cli_skip_verify_checksum: bool,
@@ -80,10 +81,16 @@ pub fn run(
                    info!(value, "=> {} Configuration with input", Label::using());
                    config.clone().run_workflow(Some(value.to_string()), &options);
                }),
                | Some(_) | None => match cli_input {
                    | Some(values) if !values.is_empty() => values.par_iter().for_each(|value| {
                        info!(value, "=> {} CLI input", Label::using());
                        config.clone().run_workflow(Some(value.to_string()), &options);
                    }),
                    | Some(_) | None => {
                        info!("=> {} Configuration with {}", Label::using(), Label::fmt_not_found("NO INPUTS"));
                        config.run_workflow(None, &options);
                    }
                },
            };
        }
        | None => error!("=> {} Could not import configuration", Label::fail()),
+2 −0
Original line number Diff line number Diff line
@@ -70,6 +70,7 @@ fn main() -> Void {
            config,
            reporter,
            output,
            input,
            dry_run,
            offline,
            skip_verify_checksum,
@@ -80,6 +81,7 @@ fn main() -> Void {
            config,
            reporter,
            output,
            input,
            *dry_run,
            *offline,
            *skip_verify_checksum,
+14 −14
Original line number Diff line number Diff line
@@ -117,21 +117,21 @@ pub struct Rule {
}
impl Config {
    pub fn get_environment_variables(self, module: Option<Module>, input: Option<String>) -> HashMap<String, String> {
        match input {
            | Some(value) => {
                let config_vars = self.variables.clone().unwrap_or_default();
                let module_vars = module.unwrap().variables.clone().unwrap_or_default();
                let mut envs = EnvironmentValue::get_from_serde(&config_vars);
        let parent = PathBuf::from(input.clone().unwrap_or_default())
            .file_name()
            .unwrap()
            .to_str()
            .unwrap()
            .to_string();
                let parent = PathBuf::from(value.clone()).file_name().unwrap().to_str().unwrap().to_string();
                envs.extend(EnvironmentValue::get_from_serde(&module_vars));
        envs.insert("INPUT".to_string(), input.unwrap_or_default());
                envs.insert("INPUT".to_string(), value);
                envs.insert("PARENT_DIRECTORY".to_string(), parent);
        println!("Envs: {:#?}", envs);
                debug!("=> {} Environment variables: {:#?}", Label::using(), envs.dimmed());
                envs
            }
            | None => HashMap::new(),
        }
    }
    /// Get inputs from input attribute for concurrent workflow execution
    ///
    /// See [InputAttribute](crate::InputAttribute) for more details