Skip to content

Commit 774a296

Browse files
authored
Feat(cli): Add Colors to CLI Status (#329)
* Feat(cli): Add colors to Cli Status * Feat(cli): Cli Status Colors - Add colors to brackets and maintain bg * cli: use AnsiColors * cli: rename * cli: add flow colors
1 parent 56e700f commit 774a296

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,3 +105,4 @@ neo4rs = "0.8.0"
105105
bytes = "1.10.1"
106106
rand = "0.9.0"
107107
indoc = "2.0.6"
108+
owo-colors = "4.2.0"

src/setup/states.rs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
use crate::prelude::*;
1515

1616
use indenter::indented;
17+
use owo_colors::{AnsiColors, OwoColorize};
1718
use std::fmt::Debug;
1819
use std::fmt::{Display, Write};
1920
use std::hash::Hash;
@@ -274,14 +275,17 @@ impl<K, S, C: ResourceSetupStatusCheck> std::fmt::Display for ResourceSetupInfo<
274275
Some(SetupChangeType::Invalid) => "INVALID",
275276
None => "USER MANAGED",
276277
};
277-
writeln!(f, "[ {:^9} ] {}", status_code, self.description)?;
278+
let status_str = format!("[ {:^9} ]", status_code);
279+
let status_full = status_str.color(AnsiColors::Cyan);
280+
let desc_colored = self.description.color(AnsiColors::BrightWhite);
281+
writeln!(f, "{} {}", status_full, desc_colored)?;
278282
if let Some(status_check) = &self.status_check {
279283
let changes = status_check.describe_changes();
280284
if !changes.is_empty() {
281285
let mut f = indented(f).with_str(INDENT);
282-
writeln!(f, "TODO:")?;
286+
writeln!(f, "{}", "TODO:".color(AnsiColors::BrightBlack))?;
283287
for change in changes {
284-
writeln!(f, " - {}", change)?;
288+
writeln!(f, " - {}", change.color(AnsiColors::BrightBlack))?;
285289
}
286290
writeln!(f)?;
287291
}
@@ -385,7 +389,12 @@ impl std::fmt::Display for FormattedFlowSetupStatusCheck<'_> {
385389
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
386390
let flow_ssc = self.1;
387391

388-
write!(f, "{} Flow: {}\n", ObjectSetupStatusCode(flow_ssc), self.0)?;
392+
write!(
393+
f,
394+
"{} {}\n",
395+
ObjectSetupStatusCode(flow_ssc).to_string().color(AnsiColors::Cyan),
396+
format!("Flow: {}", self.0).color(AnsiColors::White)
397+
)?;
389398

390399
let mut f = indented(f).with_str(INDENT);
391400
write!(f, "{}", flow_ssc.tracking_table)?;

0 commit comments

Comments
 (0)