diff --git a/src/cmds/cmd.rs b/src/cmds/cmd.rs index 68f5fad..446ede1 100644 --- a/src/cmds/cmd.rs +++ b/src/cmds/cmd.rs @@ -448,12 +448,11 @@ fn get_tree_from_context<'a>( } /// Prepare state needed for running commands. -#[allow(clippy::type_complexity)] fn get_command_environment<'a>( app_context: &'a model::ApplicationContext, context: &model::TreeContext, params: &CmdParams, -) -> Option<(Option, &'a String, Vec<(String, String)>)> { +) -> Option<(Option, &'a String, model::Environment)> { let (config, tree) = get_tree_from_context(app_context, context, params)?; // Trees must have a valid path available. let Ok(tree_path) = tree.path_as_ref() else { @@ -489,7 +488,7 @@ fn expand_and_run_command( path: &str, shell_params: &ShellParams, params: &CmdParams, - env: &Vec<(String, String)>, + env: &model::Environment, ) -> Result { let mut exit_status = errors::EX_OK; // Create a sequence of the command names to run including pre and post-commands. @@ -706,7 +705,7 @@ fn run_cmd_depth_first_parallel( fn run_cmd_vec( path: &str, shell_params: &ShellParams, - env: &Vec<(String, String)>, + env: &model::Environment, cmd_seq_vec: &[Vec], params: &CmdParams, ) -> Result<(), i32> { diff --git a/src/eval.rs b/src/eval.rs index 4787a29..7d54430 100644 --- a/src/eval.rs +++ b/src/eval.rs @@ -417,8 +417,8 @@ pub fn environment( app_context: &model::ApplicationContext, config: &model::Configuration, context: &model::TreeContext, -) -> Vec<(String, String)> { - let mut result = Vec::new(); +) -> model::Environment { + let mut result = model::Environment::new(); let mut vars = Vec::new(); // Evaluate environment variables defined at global scope. diff --git a/src/model.rs b/src/model.rs index 70faf03..982f247 100644 --- a/src/model.rs +++ b/src/model.rs @@ -29,6 +29,9 @@ pub type GraftName = String; /// Configuration Node IDs pub type ConfigId = NodeId; +/// Environment variables are set when running commands. +pub(crate) type Environment = Vec<(String, String)>; + /// Config files can define a sequence of variables that are /// iteratively calculated. Variables can reference other /// variables in their Tree, Garden, and Configuration scopes.