No description
Find a file
2018-07-02 10:51:14 -04:00
examples Add case sensitive option for ArgEnum 2017-11-15 18:49:55 +01:00
src Add case sensitive option for ArgEnum 2017-11-15 18:49:55 +01:00
tests Add case sensitive option for ArgEnum 2017-11-15 18:49:55 +01:00
.gitignore init 2017-11-12 19:04:58 +01:00
.travis.yml init 2017-11-12 19:04:58 +01:00
appveyor.yml init 2017-11-12 19:04:58 +01:00
Cargo.toml Update Cargo.toml metadata. 2017-11-12 20:58:36 +01:00
LICENSE init 2017-11-12 19:04:58 +01:00
README.md init 2017-11-12 19:04:58 +01:00

clap-derives

Build Status Build status

Clap custom derives.

#[macro_use]
extern crate clap;
#[macro_use]
extern crate clap_derive;

use clap::{App, Arg};

#[derive(ArgEnum, Debug)]
enum ArgChoice {
    Foo,
    Bar,
    Baz,
}

fn main() {
    let matches = App::new(env!("CARGO_PKG_NAME"))
            .arg(Arg::with_name("arg")
                .required(true)
                .takes_value(true)
                .possible_values(&ArgChoice::variants())
            ).get_matches();
    
    let t = value_t!(matches.value_of("arg"), ArgChoice)
        .unwrap_or_else(|e| e.exit());

    println!("{:?}", t);
}