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
use bpaf::*;
#[derive(Debug, Clone)]
#[allow(dead_code)]
struct Opts {
width: usize,
height: usize,
}
fn main() {
let width = short('w').argument::<usize>("WIDTH").fallback(10);
let height = short('h').argument::<usize>("HEIGHT").fallback(10);
let parser = construct!(Opts { width, height });
let cmd = positional::<String>("")
.guard(|s| s == "cmd", "")
.optional()
.hide();
let combined_parser = construct!(cmd, parser).map(|x| x.1);
let opts = combined_parser.to_options().run();
println!("{:?}", opts);
}