use std::fmt::Display;
use yansi::Paint;
use yansi::Painted;
#[derive(Clone, Debug)]
pub enum Message {
Error(String),
Warn(String),
Info(String),
}
impl Message {
fn color(&self) -> Painted<&String> {
match self {
Self::Error(msg) => msg.bold().red(),
Self::Warn(msg) => msg.bold().yellow(),
Self::Info(msg) => msg.bold().blue(),
}
}
pub fn display(&self) {
println!("{self}")
}
}
impl Display for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.color())
}
}