1use clap::Args;
2use clap::ValueEnum;
3
4#[derive(Args, Debug)]
5pub(crate) struct ImplicitParsers {
6 #[arg(short = 'O')]
8 optimization: Option<usize>,
9
10 #[arg(short = 'I', value_name = "DIR", value_hint = clap::ValueHint::DirPath)]
12 include: Option<std::path::PathBuf>,
13
14 #[arg(long)]
16 bind: Option<std::net::IpAddr>,
17
18 #[arg(long)]
20 sleep: Option<jiff::SignedDuration>,
21
22 #[arg(long)]
24 bump_level: Option<BumpLevel>,
25}
26
27#[derive(Debug, Clone, Copy, ValueEnum)]
28#[value(rename_all = "kebab-case")]
29pub(crate) enum BumpLevel {
30 Major,
32 Minor,
34 Patch,
36}
37
38impl std::fmt::Display for BumpLevel {
39 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
40 use clap::ValueEnum;
41
42 self.to_possible_value()
43 .expect("no values are skipped")
44 .get_name()
45 .fmt(f)
46 }
47}
48
49impl std::str::FromStr for BumpLevel {
50 type Err = String;
51
52 fn from_str(s: &str) -> Result<Self, Self::Err> {
53 use clap::ValueEnum;
54
55 for variant in Self::value_variants() {
56 if variant.to_possible_value().unwrap().matches(s, false) {
57 return Ok(*variant);
58 }
59 }
60 Err(format!("Invalid variant: {s}"))
61 }
62}