1use colored::{Color, Colorize};
8
9#[must_use]
11pub fn success(text: &str) -> colored::ColoredString {
12 text.green()
13}
14
15#[must_use]
17pub fn warning(text: &str) -> colored::ColoredString {
18 text.yellow()
19}
20
21#[must_use]
23pub fn error(text: &str) -> colored::ColoredString {
24 text.red()
25}
26
27#[must_use]
29pub fn heading(text: &str) -> colored::ColoredString {
30 text.cyan().bold()
31}
32
33#[must_use]
35pub fn subheading(text: &str) -> colored::ColoredString {
36 text.blue().bold()
37}
38
39#[must_use]
41pub fn important(text: &str) -> colored::ColoredString {
42 text.bright_white()
43}
44
45#[must_use]
47pub fn secondary(text: &str) -> colored::ColoredString {
48 text.bright_black()
49}
50
51#[must_use]
53pub fn command(text: &str) -> colored::ColoredString {
54 text.cyan()
55}
56
57#[must_use]
59pub fn url(text: &str) -> colored::ColoredString {
60 text.cyan().underline()
61}
62
63#[must_use]
65pub fn key(text: &str) -> colored::ColoredString {
66 text.yellow()
67}
68
69#[must_use]
71pub fn value(text: &str) -> colored::ColoredString {
72 text.bright_white()
73}
74
75#[must_use]
77pub fn node_status(status: &str) -> colored::ColoredString {
78 match status.to_lowercase().as_str() {
79 "running" => format!("{} ●", status).green(),
80 "stopped" => format!("{} ○", status).yellow(),
81 "error" => format!("{} ✕", status).red(),
82 _ => format!("{} ?", status).bright_black(),
83 }
84}
85
86#[must_use]
88pub fn numeric_value(
89 value: f64,
90 warning_threshold: f64,
91 error_threshold: f64,
92) -> colored::ColoredString {
93 if value >= error_threshold {
94 format!("{value:.1}").red()
95 } else if value >= warning_threshold {
96 format!("{value:.1}").yellow()
97 } else {
98 format!("{value:.1}").green()
99 }
100}
101
102#[must_use]
104pub fn table_header(text: &str) -> colored::ColoredString {
105 text.blue().bold()
106}
107
108#[must_use]
110pub fn separator() -> colored::ColoredString {
111 "---------------------------------------------------------------------------------"
112 .bright_black()
113}
114
115#[must_use]
117pub fn custom(text: &str, color: Color) -> colored::ColoredString {
118 text.color(color)
119}
120
121#[must_use]
123pub fn bold(text: &str) -> colored::ColoredString {
124 text.bold()
125}
126
127#[must_use]
129pub fn italic(text: &str) -> colored::ColoredString {
130 text.italic()
131}
132
133#[must_use]
135pub fn code(text: &str) -> colored::ColoredString {
136 text.white().on_bright_black()
137}