From 8018126d033925db0c4375b1108cb535cd7deb95 Mon Sep 17 00:00:00 2001 From: Param Arora Date: Thu, 17 Apr 2025 14:21:05 +0530 Subject: [PATCH 1/5] Feat(cli): Add colors to Cli Status --- Cargo.toml | 1 + src/setup/states.rs | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 62d3d4512..1dc28c4f2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -105,3 +105,4 @@ neo4rs = "0.8.0" bytes = "1.10.1" rand = "0.9.0" indoc = "2.0.6" +owo-colors = "4.2.0" diff --git a/src/setup/states.rs b/src/setup/states.rs index 3ccebc5e1..66702e9b0 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -14,6 +14,7 @@ use crate::prelude::*; use indenter::indented; +use owo_colors::OwoColorize; use std::fmt::Debug; use std::fmt::{Display, Write}; use std::hash::Hash; @@ -274,14 +275,18 @@ impl std::fmt::Display for ResourceSetupInfo< Some(SetupChangeType::Invalid) => "INVALID", None => "USER MANAGED", }; - writeln!(f, "[ {:^9} ] {}", status_code, self.description)?; + // Colors + let status_bg = status_code.on_truecolor(0x5c, 0xe1, 0xe6); + let status_colored = status_bg.truecolor(0xff, 0xff, 0xff); + let desc_colored = self.description.truecolor(0xff, 0xff, 0xff); + writeln!(f, "[ {:^9} ] {}", status_colored, desc_colored)?; if let Some(status_check) = &self.status_check { let changes = status_check.describe_changes(); if !changes.is_empty() { let mut f = indented(f).with_str(INDENT); - writeln!(f, "TODO:")?; + writeln!(f, "{}", "TODO:".truecolor(0xae, 0xae, 0xae))?; for change in changes { - writeln!(f, " - {}", change)?; + writeln!(f, " - {}", change.truecolor(0xae, 0xae, 0xae))?; } writeln!(f)?; } From b30f668318de6a6dc9edc0fa95df1ce3554ab1f3 Mon Sep 17 00:00:00 2001 From: Param Arora Date: Thu, 17 Apr 2025 14:42:35 +0530 Subject: [PATCH 2/5] Feat(cli): Cli Status Colors - Add colors to brackets and maintain bg --- src/setup/states.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/setup/states.rs b/src/setup/states.rs index 66702e9b0..dbd9855e0 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -267,6 +267,7 @@ pub struct ResourceSetupInfo { impl std::fmt::Display for ResourceSetupInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + let cyan = (0x5c, 0xe1, 0xe6); let status_code = match self.status_check.as_ref().map(|c| c.change_type()) { Some(SetupChangeType::NoChange) => "READY", Some(SetupChangeType::Create) => "TO CREATE", @@ -275,11 +276,10 @@ impl std::fmt::Display for ResourceSetupInfo< Some(SetupChangeType::Invalid) => "INVALID", None => "USER MANAGED", }; - // Colors - let status_bg = status_code.on_truecolor(0x5c, 0xe1, 0xe6); - let status_colored = status_bg.truecolor(0xff, 0xff, 0xff); + let status_str = format!("[ {:^9} ]", status_code); + let status_full = status_str.truecolor(cyan.0, cyan.1, cyan.2); let desc_colored = self.description.truecolor(0xff, 0xff, 0xff); - writeln!(f, "[ {:^9} ] {}", status_colored, desc_colored)?; + writeln!(f, "{} {}", status_full, desc_colored)?; if let Some(status_check) = &self.status_check { let changes = status_check.describe_changes(); if !changes.is_empty() { From dfa2d04b2c9d25dde731c95537c9affc7eb8b428 Mon Sep 17 00:00:00 2001 From: Param Arora Date: Fri, 18 Apr 2025 18:05:59 +0530 Subject: [PATCH 3/5] cli: use AnsiColors --- src/setup/states.rs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/setup/states.rs b/src/setup/states.rs index dbd9855e0..a1c19e570 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -14,7 +14,7 @@ use crate::prelude::*; use indenter::indented; -use owo_colors::OwoColorize; +use owo_colors::{AnsiColors, OwoColorize}; use std::fmt::Debug; use std::fmt::{Display, Write}; use std::hash::Hash; @@ -267,7 +267,6 @@ pub struct ResourceSetupInfo { impl std::fmt::Display for ResourceSetupInfo { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - let cyan = (0x5c, 0xe1, 0xe6); let status_code = match self.status_check.as_ref().map(|c| c.change_type()) { Some(SetupChangeType::NoChange) => "READY", Some(SetupChangeType::Create) => "TO CREATE", @@ -277,16 +276,16 @@ impl std::fmt::Display for ResourceSetupInfo< None => "USER MANAGED", }; let status_str = format!("[ {:^9} ]", status_code); - let status_full = status_str.truecolor(cyan.0, cyan.1, cyan.2); - let desc_colored = self.description.truecolor(0xff, 0xff, 0xff); + let status_full = status_str.color(AnsiColors::Cyan); + let desc_colored = self.description.color(AnsiColors::BrightWhite); writeln!(f, "{} {}", status_full, desc_colored)?; if let Some(status_check) = &self.status_check { let changes = status_check.describe_changes(); if !changes.is_empty() { let mut f = indented(f).with_str(INDENT); - writeln!(f, "{}", "TODO:".truecolor(0xae, 0xae, 0xae))?; + writeln!(f, "{}", "CHANGE:".color(AnsiColors::BrightBlack))?; for change in changes { - writeln!(f, " - {}", change.truecolor(0xae, 0xae, 0xae))?; + writeln!(f, " - {}", change.color(AnsiColors::BrightBlack))?; } writeln!(f)?; } From d9861f78c40873026e164928029614741df02a58 Mon Sep 17 00:00:00 2001 From: Param Arora Date: Fri, 18 Apr 2025 18:24:14 +0530 Subject: [PATCH 4/5] cli: rename --- src/setup/states.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/setup/states.rs b/src/setup/states.rs index a1c19e570..a0426adda 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -283,7 +283,7 @@ impl std::fmt::Display for ResourceSetupInfo< let changes = status_check.describe_changes(); if !changes.is_empty() { let mut f = indented(f).with_str(INDENT); - writeln!(f, "{}", "CHANGE:".color(AnsiColors::BrightBlack))?; + writeln!(f, "{}", "TODO:".color(AnsiColors::BrightBlack))?; for change in changes { writeln!(f, " - {}", change.color(AnsiColors::BrightBlack))?; } From 95728fa36026b0ab96acf3ff8e3771e80cd4419b Mon Sep 17 00:00:00 2001 From: Param Arora Date: Sat, 19 Apr 2025 02:26:03 +0530 Subject: [PATCH 5/5] cli: add flow colors --- src/setup/states.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/setup/states.rs b/src/setup/states.rs index a0426adda..516b6dbcf 100644 --- a/src/setup/states.rs +++ b/src/setup/states.rs @@ -389,7 +389,12 @@ impl std::fmt::Display for FormattedFlowSetupStatusCheck<'_> { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let flow_ssc = self.1; - write!(f, "{} Flow: {}\n", ObjectSetupStatusCode(flow_ssc), self.0)?; + write!( + f, + "{} {}\n", + ObjectSetupStatusCode(flow_ssc).to_string().color(AnsiColors::Cyan), + format!("Flow: {}", self.0).color(AnsiColors::White) + )?; let mut f = indented(f).with_str(INDENT); write!(f, "{}", flow_ssc.tracking_table)?;