From 7eff6523b5e33b35bbcee6d17f7a882bd096c951 Mon Sep 17 00:00:00 2001 From: darimari21 <130467505+darimari21@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:21:08 +0000 Subject: [PATCH 1/2] fixed https://github.com/console-rs/console/issues/197 --- src/utils.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/utils.rs b/src/utils.rs index cfecc78f..07235a1e 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -17,8 +17,15 @@ fn strip_ansi_codes(s: &str) -> &str { } fn default_colors_enabled(out: &Term) -> bool { - (out.features().colors_supported() - && &env::var("CLICOLOR").unwrap_or_else(|_| "1".into()) != "0") + let clicolor_enabled = out.features().colors_supported() + && &env::var("CLICOLOR").unwrap_or_else(|_| "1".into()) != "0"; + + let no_color_enabled = match env::var("NO_COLOR") { + Ok(val) => val.to_lowercase() != "0" && val.to_lowercase() != "false", + Err(_) => false, // Dacă variabila nu este setată, presupunem că nu este activată + }; + + (clicolor_enabled && !no_color_enabled) || &env::var("CLICOLOR_FORCE").unwrap_or_else(|_| "0".into()) != "0" } From 4473a6127b4c4bc7ca378340a8b3f60f8831f37b Mon Sep 17 00:00:00 2001 From: darimari21 <130467505+darimari21@users.noreply.github.com> Date: Thu, 18 Jan 2024 22:22:01 +0000 Subject: [PATCH 2/2] fixed https://github.com/console-rs/console/issues/197 --- src/utils.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.rs b/src/utils.rs index 07235a1e..ffc65c8d 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -22,7 +22,7 @@ fn default_colors_enabled(out: &Term) -> bool { let no_color_enabled = match env::var("NO_COLOR") { Ok(val) => val.to_lowercase() != "0" && val.to_lowercase() != "false", - Err(_) => false, // Dacă variabila nu este setată, presupunem că nu este activată + Err(_) => false, }; (clicolor_enabled && !no_color_enabled)