-
-
Notifications
You must be signed in to change notification settings - Fork 1k
/
derive.rs
38 lines (31 loc) · 861 Bytes
/
derive.rs
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 clap::{Parser, Subcommand};
#[derive(Parser, Debug)]
#[command(name = "my-app")]
pub struct BasicCommand {
#[clap(short, global = true)]
config: bool,
#[clap(short, conflicts_with("config"))]
v: bool,
#[command(subcommand)]
test: Option<BasicCommandSubCommand>
}
#[derive(Subcommand, Debug)]
pub enum BasicCommandSubCommand {
/// Subcommand
Test {
#[clap(short, action(clap::ArgAction::Count))]
debug: u8,
},
}
// Checks to make sure boolean valued "Flag options" do not generate
// suggestions for a parameter. i.e:
// --boolean_flag=BOOLEAN_FLAG
//
// This is both confusing and suggest erroneous behavior as clap will fail if you
// pass a value to a boolean flag
#[derive(Parser, Debug)]
#[command(name = "my-app")]
pub struct FlagWithoutValue {
#[clap(long)]
boolean_flag: bool,
}