From 731d76db43271abc50e0088a9e9731453e60f0c4 Mon Sep 17 00:00:00 2001 From: FlareFlo Date: Wed, 25 Oct 2023 22:00:48 +0200 Subject: [PATCH] Add conditional for color settings in error reporting via override, disable on windows per default --- src/main.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index f00358a..27f96a3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -21,7 +21,25 @@ pub const GIT_TAG: &str = env!("GIT_TAG"); fn main() -> Result<()> { env::set_var("RUST_BACKTRACE", "1"); - color_eyre::install()?; + + let enable_color = if let Ok(force_color) = env::var("FORCE_SET_COLOR") { + force_color.parse::() + .expect("FORCE_COLOR was not 'false' or 'true'") + } else { + if cfg!(windows) { + false + } else { + true + } + }; + + if enable_color { + color_eyre::install()?; + } else { + color_eyre::config::HookBuilder::new() + .theme(color_eyre::config::Theme::new()) + .install()?; + } let command = build_command_structure().get_matches(); branch_subcommands(command)?;