pub mod project;
pub mod task;
use clap::ValueEnum;
use std::fmt;
use std::str::FromStr;
#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
pub enum OutputFormat {
#[default]
Table,
Json,
Csv,
Markdown,
}
impl fmt::Display for OutputFormat {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str(match self {
Self::Table => "table",
Self::Json => "json",
Self::Csv => "csv",
Self::Markdown => "markdown",
})
}
}
impl FromStr for OutputFormat {
type Err = String;
fn from_str(s: &str) -> Result<Self, Self::Err> {
match s.to_ascii_lowercase().as_str() {
"table" => Ok(Self::Table),
"json" => Ok(Self::Json),
"csv" => Ok(Self::Csv),
"markdown" | "md" => Ok(Self::Markdown),
other => Err(format!(
"unsupported output format '{other}'; expected table, json, csv, or markdown"
)),
}
}
}
pub type TaskOutputFormat = OutputFormat;
pub type ProjectOutputFormat = OutputFormat;