summaryrefslogtreecommitdiffstats
path: root/vendor/xflags/examples/hello.rs
blob: 91dc3fd8a46c84669d490c9d4f8b990d1a2b9961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
mod flags {
    xflags::xflags! {
        cmd hello {
            required name: String
            optional -e, --emoji
        }
    }
}

fn main() {
    match flags::Hello::from_env() {
        Ok(flags) => {
            let bang = if flags.emoji { "❣️" } else { "!" };
            println!("Hello {}{}", flags.name, bang);
        }
        Err(err) => {
            eprintln!("{}", err);
            std::process::exit(1)
        }
    }
}