1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
use {
argh::FromArgs,
};
#[derive(Debug, FromArgs)]
pub struct Args {
#[argh(switch, short = 'v')]
pub version: bool,
#[argh(option, short='f')]
pub format: Option<Format>,
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum Format {
Svg,
Html,
}
impl std::str::FromStr for Format {
type Err = String;
fn from_str(s: &str) -> Result<Self, String> {
match s.to_lowercase().as_ref() {
"s" | "svg" => Ok(Self::Svg),
"h" | "html" => Ok(Self::Html),
_ => Err(format!("unrecognized format {:?}", s))
}
}
}