no_import/
no_import.rs

1//! You don't need to import bpaf in order to use it, it will look ugly though
2
3#[allow(dead_code)]
4#[derive(Debug, Clone)]
5struct Out {
6    debug: bool,
7    speed: f64,
8}
9
10fn main() {
11    // A flag, true if used in the command line. Can be required, this one is optional
12    let debug = bpaf::short('d')
13        .long("debug")
14        .help("Activate debug mode")
15        .switch();
16
17    // an argument, parsed and with default value
18    let speed = bpaf::Parser::fallback(
19        bpaf::short('s')
20            .long("speed")
21            .help("Set speed")
22            .argument::<f64>("SPEED"),
23        42.0,
24    );
25
26    // packing things in a struct assumes parser for each field is in scope.
27    let opt = bpaf::Parser::to_options(bpaf::construct!(Out { debug, speed })).run();
28
29    println!("{:#?}", opt);
30}