#[derive(Clone, Copy, Debug)]
pub struct Colors {
pub blue: &'static str,
pub green: &'static str,
pub dim: &'static str,
pub reset: &'static str,
}
impl Default for Colors {
fn default() -> Self {
Self::OFF
}
}
impl Colors {
pub const ON: Self = Self {
blue: "\x1b[34m",
green: "\x1b[32m",
dim: "\x1b[2m",
reset: "\x1b[0m",
};
pub const OFF: Self = Self {
blue: "",
green: "",
dim: "",
reset: "",
};
pub fn new(enabled: bool) -> Self {
if enabled { Self::ON } else { Self::OFF }
}
pub fn is_enabled(&self) -> bool {
!self.blue.is_empty()
}
}