2018-04-09 09:14:28 +00:00
|
|
|
#[macro_use]
|
2018-07-02 18:45:17 +00:00
|
|
|
extern crate clap;
|
2018-04-09 09:14:28 +00:00
|
|
|
|
2018-07-02 18:45:17 +00:00
|
|
|
use clap::{AppSettings, Clap};
|
2018-04-09 09:14:28 +00:00
|
|
|
|
2018-07-02 18:45:17 +00:00
|
|
|
#[derive(Clap, Debug)]
|
2018-04-09 09:14:28 +00:00
|
|
|
// https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(raw(setting = "AppSettings::InferSubcommands"))]
|
2018-04-09 09:14:28 +00:00
|
|
|
enum Opt {
|
|
|
|
// https://docs.rs/clap/2/clap/struct.App.html#method.alias
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(name = "foo", alias = "foobar")]
|
2018-04-09 09:14:28 +00:00
|
|
|
Foo,
|
|
|
|
// https://docs.rs/clap/2/clap/struct.App.html#method.aliases
|
2018-07-02 18:45:17 +00:00
|
|
|
#[clap(name = "bar", raw(aliases = r#"&["baz", "fizz"]"#))]
|
2018-04-09 09:14:28 +00:00
|
|
|
Bar,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2018-07-02 18:45:17 +00:00
|
|
|
let opt = Opt::parse();
|
2018-04-09 09:14:28 +00:00
|
|
|
println!("{:?}", opt);
|
|
|
|
}
|