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
use bpaf::*;
#[derive(Clone, Debug)]
#[allow(dead_code)]
struct Opts {
speed: f64,
distance: f64,
}
fn opts() -> Opts {
let speed = short('k')
.long("speed") .help("speed in KPH") .argument("SPEED") .from_str::<f64>() .map(|s| s / 0.62); let distance = short('d')
.long("distance")
.help("distance in miles")
.argument("DISTANCE")
.from_str::<f64>();
(construct!(Opts { speed, distance }))
.to_options()
.descr("Accept speed and distance, print them.")
.run()
}
fn main() {
let opts = opts();
println!("Options: {:?}", opts);
}