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
39
40
41
42
43
44
45
46
#[derive(Debug, Clone)]
pub struct Opt {
pub(crate) name: String,
pub(crate) default: Option<String>,
pub(crate) help: Option<String>,
pub(crate) short: Option<String>,
pub(crate) long: Option<String>,
}
impl Opt {
pub fn new(name: &str) -> Self {
Self {
name: name.into(),
default: None,
help: None,
short: None,
long: None,
}
}
pub fn default_value(mut self, default: &str) -> Self {
self.default = Some(default.into());
self
}
pub fn help(mut self, help: &str) -> Self {
self.help = Some(help.into());
self
}
pub fn short(mut self, short: &str) -> Self {
self.short = Some(short.into());
self
}
pub fn long(mut self, long: &str) -> Self {
self.long = Some(long.into());
self
}
}