1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
use std::str::FromStr;

/// Supported output formats.
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum Format {
    /// Prettified JSON.
    Long,
}

impl FromStr for Format {
    type Err = anyhow::Error;

    fn from_str(s: &str) -> Result<Self, Self::Err> {
        match s.to_lowercase().as_str() {
            "long" => Ok(Format::Long),
            _ => Err(anyhow::anyhow!(format!("Invalid format value: '{}'", s))),
        }
    }
}