summaryrefslogtreecommitdiffstats
path: root/src/config/mod.rs
diff options
context:
space:
mode:
authorsigoden <sigoden@gmail.com>2023-03-11 18:53:36 +0800
committerGitHub <noreply@github.com>2023-03-11 18:53:36 +0800
commitcfb6ce6958751da5e13683ea07f42a5dbc4eae01 (patch)
treec7ec60ba7c1d2e37225ae6b1476057a18e2eb987 /src/config/mod.rs
parentdc09cb38d480342c9fe781a19fe72d2bb892b70c (diff)
downloadaichat-cfb6ce6958751da5e13683ea07f42a5dbc4eae01.tar.gz
feat: support light theme (#65)
There are two ways to enable the light theme: - add `light_theme: true` to config.yaml - use `AICHAT_LIGHT_THEME=true` env var
Diffstat (limited to 'src/config/mod.rs')
-rw-r--r--src/config/mod.rs20
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,
+ _ => {}
+ }
+}