#[derive(Clone)]
pub enum Format {
Json,
Plain,
Color,
Modern,
}
impl Format {
pub fn from_str(string: impl AsRef<str>) -> Option<Format> {
match string.as_ref() {
"json" => Some(Format::Json),
"plain" => Some(Format::Plain),
"color" => Some(Format::Color),
"modern" => Some(Format::Modern),
_ => None,
}
}
pub fn is_colored(&self) -> bool {
match self {
Format::Color | Format::Modern => true,
_ => false,
}
}
pub fn has_icons(&self) -> bool {
match self {
Format::Modern => true,
_ => false,
}
}
}
impl Default for Format {
fn default() -> Format {
Format::Json
}
}