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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use clap::Clap;
use log::LevelFilter;
#[derive(Clap, Debug)]
#[clap(about, author, version)]
#[cfg_attr(feature = "colors", clap(setting(clap::AppSettings::ColoredHelp)))]
pub struct Args {
#[clap(conflicts_with("config-path"), conflicts_with("profile"), long, short)]
pub branch: Option<String>,
#[clap(
conflicts_with("features"),
conflicts_with("force"),
conflicts_with("git"),
conflicts_with("interactive"),
conflicts_with("name"),
conflicts_with("parameters"),
conflicts_with("profile"),
long,
short
)]
pub config_path: bool,
#[clap(long, short)]
pub features: Option<Vec<String>>,
#[clap(conflicts_with("config-path"), long)]
pub force: bool,
#[clap(
conflicts_with("profile"),
long,
required_unless("config-path"),
required_unless("profile"),
short
)]
pub git: Option<String>,
#[clap(long, short)]
pub interactive: bool,
#[clap(long, required_unless("config-path"), short)]
pub name: Option<String>,
#[clap(allow_hyphen_values(true), multiple(true), last(true))]
pub parameters: Vec<String>,
#[clap(
conflicts_with("git"),
long,
required_unless("config-path"),
required_unless("git"),
short
)]
pub profile: Option<String>,
#[clap(long, short, parse(from_occurrences))]
pub verbosity: u8,
}
impl Args {
pub fn log_filter_from_verbose(&self) -> LevelFilter {
match self.verbosity {
0 => LevelFilter::Off,
1 => LevelFilter::Error,
2 => LevelFilter::Warn,
3 => LevelFilter::Info,
4 => LevelFilter::Debug,
5..=std::u8::MAX => LevelFilter::Trace,
}
}
}