use clap::ValueEnum;
use clap::builder::PossibleValue;
use std::fmt::Display;
#[derive(Clone, Debug)]
pub enum StdioLogFmt {
Concise,
Pretty,
Json,
}
impl ValueEnum for StdioLogFmt {
fn value_variants<'a>() -> &'a [Self] {
&[Self::Concise, Self::Pretty, Self::Json]
}
fn to_possible_value(&self) -> Option<PossibleValue> {
match self {
Self::Concise => Some(PossibleValue::new("concise")),
Self::Pretty => Some(PossibleValue::new("pretty")),
Self::Json => Some(PossibleValue::new("json")),
}
}
}
impl Display for StdioLogFmt {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let str = match self {
Self::Concise => "concise",
Self::Pretty => "pretty",
Self::Json => "json",
};
write!(f, "{str}")
}
}