1pub mod project;
4pub mod task;
5
6use clap::ValueEnum;
7use std::fmt;
8use std::str::FromStr;
9
10#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, ValueEnum)]
15pub enum OutputFormat {
16 #[default]
18 Table,
19 Json,
21 Csv,
23 Markdown,
25}
26
27impl fmt::Display for OutputFormat {
28 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
29 f.write_str(match self {
30 Self::Table => "table",
31 Self::Json => "json",
32 Self::Csv => "csv",
33 Self::Markdown => "markdown",
34 })
35 }
36}
37
38impl FromStr for OutputFormat {
39 type Err = String;
40
41 fn from_str(s: &str) -> Result<Self, Self::Err> {
42 match s.to_ascii_lowercase().as_str() {
43 "table" => Ok(Self::Table),
44 "json" => Ok(Self::Json),
45 "csv" => Ok(Self::Csv),
46 "markdown" | "md" => Ok(Self::Markdown),
47 other => Err(format!(
48 "unsupported output format '{other}'; expected table, json, csv, or markdown"
49 )),
50 }
51 }
52}
53
54pub type TaskOutputFormat = OutputFormat;
56pub type ProjectOutputFormat = OutputFormat;