Function claui::run

source ·
pub fn run<F: Fn(&ArgMatches) + Send + Sync + 'static>(
    app: Command,
    func: F
) -> Result<(), Error>
Expand description

Run a clap Command as a GUI

Examples found in repository?
examples/fizzbuzz.rs (line 46)
43
44
45
46
47
fn main() {
    let app = Args::command();

    claui::run(app, run).unwrap();
}
More examples
Hide additional examples
examples/basic.rs (lines 8-10)
5
6
7
8
9
10
11
12
fn main() {
    let app = Command::new("Basic");

    claui::run(app, |_| {
        println!("Hello, World!");
    })
    .unwrap();
}
examples/panic.rs (lines 8-10)
5
6
7
8
9
10
11
12
fn main() {
    let command = Command::new("Panic Example");

    claui::run(command, |_| {
        panic!("This is a panic message.");
    })
    .unwrap();
}
examples/derive.rs (lines 22-28)
19
20
21
22
23
24
25
26
27
28
29
30
fn main() {
    let app = Args::command();

    claui::run(app, |matches| {
        println!("Hello, {}!", matches.get_one::<String>("name").unwrap());

        if matches.get_flag("goodbye") {
            println!("Goodbye!");
        }
    })
    .unwrap();
}
examples/builder.rs (lines 13-19)
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
fn main() {
    let app = Command::new("Builder Greeter")
        .author("Grant Handy <grantshandy@gmail.com>")
        .version("1.2.3")
        .about("A builder example for claui")
        .arg(arg!(--name [NAME] "Your name").default_value("Joe"))
        .arg(arg!(--goodbye "Say goodbye"));

    claui::run(app, |matches| {
        println!("Hello, {}!", matches.get_one::<String>("name").unwrap());

        if matches.get_flag("goodbye") {
            println!("Goodbye!");
        }
    })
    .unwrap();
}