diff options
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index a670d00..96f19db 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -54,6 +54,8 @@ pub struct Config { pub dry_run: bool, /// If set ture, start a conversation immediately upon repl pub conversation_first: bool, + /// Is ligth theme + pub light_theme: bool, /// Predefined roles #[serde(skip)] pub roles: Vec<Role>, @@ -75,6 +77,7 @@ impl Default for Config { proxy: None, dry_run: false, conversation_first: false, + light_theme: false, roles: vec![], role: None, conversation: None, @@ -409,11 +412,10 @@ impl Config { fn merge_env_vars(&mut self) { if let Ok(value) = env::var(get_env_name("dry_run")) { - match value.as_str() { - "1" | "true" => self.dry_run = true, - "0" | "false" => self.dry_run = false, - _ => {} - } + set_bool(&mut self.dry_run, &value); + } + if let Ok(value) = env::var(get_env_name("light_theme")) { + set_bool(&mut self.light_theme, &value); } } } @@ -479,3 +481,11 @@ fn get_env_name(key: &str) -> String { key.to_ascii_uppercase(), ) } + +fn set_bool(target: &mut bool, value: &str) { + match value { + "1" | "true" => *target = true, + "0" | "false" => *target = false, + _ => {} + } +} |
