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/main.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/main.rs')
| -rw-r--r-- | src/main.rs | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/src/main.rs b/src/main.rs index 1476408..3c52f0d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -34,7 +34,7 @@ use parking_lot::RwLock; use simplelog::{format_description, ConfigBuilder, LevelFilter, SimpleLogger, WriteLogger}; use std::{ env, - io::{stderr, stdin, Read}, + io::{stdin, Read}, process, sync::Arc, }; @@ -54,10 +54,8 @@ async fn main() -> Result<()> { }; setup_logger(working_mode.is_serve())?; let config = Arc::new(RwLock::new(Config::init(working_mode)?)); - let highlight = config.read().highlight; if let Err(err) = run(config, cli, text).await { - let highlight = stderr().is_terminal() && highlight; - render_error(err, highlight); + render_error(err); std::process::exit(1); } Ok(()) |
