diff --git a/src/context/mod.rs b/src/context/mod.rs index 6d915db..9475227 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -102,7 +102,10 @@ impl Context for VariableMap { None } } else { - self.variables.get(identifier) + self.variables.get(identifier).or_else(|| { + self.call_function(identifier, &Value::Empty); + None + }) } } diff --git a/src/toolbox.rs b/src/toolbox.rs new file mode 100644 index 0000000..7a151aa --- /dev/null +++ b/src/toolbox.rs @@ -0,0 +1,37 @@ +use crate::Result; + +use std::collections::HashMap; + +pub fn build(variables: &HashMap) -> Result { + let name = { + let name = if let Some(value) = variables.get("name") { + format!("--name {}", value) + } else { + String::with_capacity(0) + }; + + Value::String(name) + }; + let image = { + let image = if let Some(value) = variables.get("image") { + format!("--image {}", value) + } else { + String::with_capacity(0) + }; + + Value::String(image) + }; + + // let toolbox_command = format!("toolbox create --image {} {}", &image, &name); + // Command::new("fish") + // .arg("-c") + // .arg(&toolbox_command) + // .spawn() + // .unwrap() + // .wait() + // .unwrap(); + + println!("{} {}", image, name); + + Ok(Value::String("Built container.".to_string())) +}