use std::collections::HashMap;
use std::path::PathBuf;
#[derive(Clone, Debug)]
pub struct ExecutionContext {
pub worktree_path: PathBuf,
pub worktree_name: String,
pub item_id: String,
pub variables: HashMap<String, String>,
pub captured_outputs: HashMap<String, String>,
pub environment: HashMap<String, String>,
}
impl ExecutionContext {
pub fn new(worktree_path: PathBuf, worktree_name: String, item_id: String) -> Self {
Self {
worktree_path,
worktree_name,
item_id,
variables: HashMap::new(),
captured_outputs: HashMap::new(),
environment: HashMap::new(),
}
}
pub fn with_variable(mut self, key: String, value: String) -> Self {
self.variables.insert(key, value);
self
}
pub fn with_variables(mut self, vars: HashMap<String, String>) -> Self {
self.variables.extend(vars);
self
}
pub fn with_captured_output(mut self, key: String, value: String) -> Self {
self.captured_outputs.insert(key, value);
self
}
pub fn with_env(mut self, key: String, value: String) -> Self {
self.environment.insert(key, value);
self
}
pub fn get_variable(&self, key: &str) -> Option<&String> {
self.variables.get(key)
}
pub fn get_captured_output(&self, key: &str) -> Option<&String> {
self.captured_outputs.get(key)
}
pub fn get_env(&self, key: &str) -> Option<&String> {
self.environment.get(key)
}
}