From 4bc74f7e9006fc7f182c9dc6ea309ea83c5bb4f9 Mon Sep 17 00:00:00 2001 From: sigoden Date: Tue, 8 Oct 2024 12:38:31 +0800 Subject: 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 --- src/main.rs | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'src/main.rs') 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(()) -- cgit v1.2.3