use anstyle::{AnsiColor, Style};
pub const HEADING: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Cyan)));
pub const SUCCESS: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Green)));
pub const WARNING: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Yellow)));
pub const ERROR: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Red)));
pub const VALUE: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Yellow)));
pub const MUTED: Style = Style::new().fg_color(Some(anstyle::Color::Ansi(AnsiColor::BrightBlack)));
pub const OPTION: Style = Style::new()
.bold()
.fg_color(Some(anstyle::Color::Ansi(AnsiColor::Green)));
#[must_use]
pub fn styled(style: Style, value: &str) -> String {
if value.is_empty() {
String::new()
} else {
format!("{}{value}{}", style.render(), style.render_reset())
}
}
#[cfg(test)]
mod tests {
use super::{OPTION, styled};
#[test]
fn empty_stays_empty() {
assert_eq!(styled(OPTION, ""), "");
}
#[test]
fn wraps_nonempty() {
let out = styled(OPTION, "--help");
assert!(out.contains("--help"));
assert_ne!(out, "--help");
}
}