use clap::ValueEnum;
#[derive(Debug, Clone, Copy, Default, ValueEnum)]
pub enum OutputFormat {
#[default]
Csv,
Json,
Jsonl,
Markdown,
}
impl OutputFormat {
pub fn extension(&self) -> &'static str {
match self {
OutputFormat::Csv => "csv",
OutputFormat::Json => "json",
OutputFormat::Jsonl => "jsonl",
OutputFormat::Markdown => "md",
}
}
pub fn mime_type(&self) -> &'static str {
match self {
OutputFormat::Csv => "text/csv",
OutputFormat::Json => "application/json",
OutputFormat::Jsonl => "application/x-ndjson",
OutputFormat::Markdown => "text/markdown",
}
}
}
impl std::fmt::Display for OutputFormat {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
OutputFormat::Csv => write!(f, "csv"),
OutputFormat::Json => write!(f, "json"),
OutputFormat::Jsonl => write!(f, "jsonl"),
OutputFormat::Markdown => write!(f, "markdown"),
}
}
}