1use bpaf::*;
4
5#[allow(dead_code)]
6#[derive(Debug, Copy, Clone)]
7struct Out {
8 rect: Option<Rect>,
9 verbose: bool,
10}
11
12#[allow(dead_code)]
13#[derive(Debug, Copy, Clone)]
14struct Rect {
15 width: usize,
16 height: usize,
17}
18
19fn main() {
20 let width = short('w')
21 .long("width")
22 .help("Width of the rectangle")
23 .argument::<usize>("PX");
24
25 let height = short('h')
26 .long("height")
27 .help("Height of the rectangle")
28 .argument::<usize>("PX");
29
30 let rect = construct!(Rect { width, height })
31 .group_help("Rectangle is defined by width and height in meters")
32 .optional();
33
34 let verbose = short('v')
35 .long("verbose")
36 .help("Print computation steps")
37 .switch();
38
39 let opt = construct!(Out { verbose, rect })
40 .to_options()
41 .descr("This program calculates rectangle's area")
42 .header("vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv")
43 .footer("^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^")
44 .run();
45 println!("{:#?}", opt);
46}