use std::collections::HashMap;
#[derive(Debug, Clone)]
pub struct Variables {
global: HashMap<String, String>,
manifest: HashMap<String, String>,
local: HashMap<String, String>,
cli: HashMap<String, String>,
}
impl Variables {
pub fn new() -> Self {
Self {
global: HashMap::new(),
manifest: HashMap::new(),
local: HashMap::new(),
cli: HashMap::new(),
}
}
pub fn set_global(&mut self, key: &str, value: &str) {
self.global.insert(key.to_string(), value.to_string());
}
pub fn set_manifest(&mut self, key: &str, value: &str) {
self.manifest.insert(key.to_string(), value.to_string());
}
pub fn set_local(&mut self, key: &str, value: &str) {
self.local.insert(key.to_string(), value.to_string());
}
pub fn set_cli(&mut self, key: &str, value: &str) {
self.cli.insert(key.to_string(), value.to_string());
}
pub fn merge(&self) -> HashMap<String, String> {
let mut result = HashMap::new();
result.extend(self.global.clone());
result.extend(self.manifest.clone());
result.extend(self.local.clone());
result.extend(self.cli.clone());
result
}
}
impl Default for Variables {
fn default() -> Self {
Self::new()
}
}