diff options
| author | sigoden <sigoden@gmail.com> | 2024-10-08 12:38:31 +0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-08 12:38:31 +0800 |
| commit | 4bc74f7e9006fc7f182c9dc6ea309ea83c5bb4f9 (patch) | |
| tree | 1ed8ef0b37879ea543fe1ba2060757e4079c90ce /src/config/mod.rs | |
| parent | c211d1e43a02266226fb8d04856e703a4e6a625d (diff) | |
| download | aichat-4bc74f7e9006fc7f182c9dc6ea309ea83c5bb4f9.tar.gz | |
refactor: NO_COLOR, highlight and render_error (#915)
- If NO_COLOR is enabled, AIChat will not output any ANSI color codes.
- `config.highlight` will only affect rendering markdown
- improve rendering error
Diffstat (limited to 'src/config/mod.rs')
| -rw-r--r-- | src/config/mod.rs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/config/mod.rs b/src/config/mod.rs index 1c669a7..8e3e2c3 100644 --- a/src/config/mod.rs +++ b/src/config/mod.rs @@ -1969,10 +1969,8 @@ impl Config { if let Some(Some(v)) = read_env_bool("highlight") { self.highlight = v; } - if let Ok(value) = env::var("NO_COLOR") { - if let Some(false) = parse_bool(&value) { - self.highlight = false; - } + if *NO_COLOR { + self.highlight = false; } if let Some(Some(v)) = read_env_bool("light_theme") { self.light_theme = v; @@ -2166,14 +2164,6 @@ fn read_env_bool(key: &str) -> Option<Option<bool>> { Some(parse_bool(&value)) } -fn parse_bool(value: &str) -> Option<bool> { - match value { - "1" | "true" => Some(true), - "0" | "false" => Some(false), - _ => None, - } -} - fn complete_bool(value: bool) -> Vec<String> { vec![(!value).to_string()] } |
