use yansi::Paint;
#[derive(Debug, Clone, PartialEq, Eq)]
pub enum Severity {
Error,
Warning,
Info,
Debug,
Trace,
Help,
Custom(String, (u8, u8, u8)),
}
impl Severity {
#[must_use]
pub fn colorize(&self, text: &str) -> String {
format!(
"{}",
match self {
Self::Error => text.red(),
Self::Warning => text.yellow(),
Self::Info => text.blue(),
Self::Debug => text.magenta(),
Self::Trace => text.cyan(),
Self::Help => text.green(),
Self::Custom(_, (r, g, b)) => text.rgb(*r, *g, *b),
}
)
}
#[must_use]
pub fn as_str(&self) -> &str {
match self {
Self::Error => "error",
Self::Warning => "warning",
Self::Info => "info",
Self::Debug => "debug",
Self::Trace => "trace",
Self::Help => "help",
Self::Custom(name, _) => name,
}
}
}