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
use bpaf::*;
#[allow(dead_code)]
#[derive(Debug, Clone)]
struct Cmdline {
verbose: bool,
daemon_opts: DaemonOpts,
}
#[allow(dead_code)]
#[derive(Debug, Clone)]
struct DaemonOpts {
user: String,
group: String,
}
fn main() {
let verbose = short('v').help("switch verbosity on").switch();
let user = short('u').help("daemon user").argument::<String>("USER");
let group = short('g').help("daemon group").argument::<String>("GROUP");
let daemon_opts = construct!(DaemonOpts { user, group });
let opt = construct!(Cmdline {
verbose,
daemon_opts
})
.to_options()
.run();
println!("{:?}", opt);
}