use colored::{Color, Colorize};
#[must_use]
pub fn success(text: &str) -> colored::ColoredString {
text.green()
}
#[must_use]
pub fn warning(text: &str) -> colored::ColoredString {
text.yellow()
}
#[must_use]
pub fn error(text: &str) -> colored::ColoredString {
text.red()
}
#[must_use]
pub fn heading(text: &str) -> colored::ColoredString {
text.cyan().bold()
}
#[must_use]
pub fn subheading(text: &str) -> colored::ColoredString {
text.blue().bold()
}
#[must_use]
pub fn important(text: &str) -> colored::ColoredString {
text.bright_white()
}
#[must_use]
pub fn secondary(text: &str) -> colored::ColoredString {
text.bright_black()
}
#[must_use]
pub fn command(text: &str) -> colored::ColoredString {
text.cyan()
}
#[must_use]
pub fn url(text: &str) -> colored::ColoredString {
text.cyan().underline()
}
#[must_use]
pub fn key(text: &str) -> colored::ColoredString {
text.yellow()
}
#[must_use]
pub fn value(text: &str) -> colored::ColoredString {
text.bright_white()
}
#[must_use]
pub fn node_status(status: &str) -> colored::ColoredString {
match status.to_lowercase().as_str() {
"running" => format!("{} ●", status).green(),
"stopped" => format!("{} ○", status).yellow(),
"error" => format!("{} ✕", status).red(),
_ => format!("{} ?", status).bright_black(),
}
}
#[must_use]
pub fn numeric_value(
value: f64,
warning_threshold: f64,
error_threshold: f64,
) -> colored::ColoredString {
if value >= error_threshold {
format!("{value:.1}").red()
} else if value >= warning_threshold {
format!("{value:.1}").yellow()
} else {
format!("{value:.1}").green()
}
}
#[must_use]
pub fn table_header(text: &str) -> colored::ColoredString {
text.blue().bold()
}
#[must_use]
pub fn separator() -> colored::ColoredString {
"---------------------------------------------------------------------------------"
.bright_black()
}
#[must_use]
pub fn custom(text: &str, color: Color) -> colored::ColoredString {
text.color(color)
}
#[must_use]
pub fn bold(text: &str) -> colored::ColoredString {
text.bold()
}
#[must_use]
pub fn italic(text: &str) -> colored::ColoredString {
text.italic()
}
#[must_use]
pub fn code(text: &str) -> colored::ColoredString {
text.white().on_bright_black()
}