clap/examples/subcommand_aliases.rs

22 lines
561 B
Rust
Raw Normal View History

2018-04-09 09:14:28 +00:00
#[macro_use]
extern crate clap;
2018-04-09 09:14:28 +00:00
use clap::{AppSettings, Clap};
2018-04-09 09:14:28 +00:00
#[derive(Clap, Debug)]
2018-04-09 09:14:28 +00:00
// https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands
#[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
#[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
#[clap(name = "bar", raw(aliases = r#"&["baz", "fizz"]"#))]
2018-04-09 09:14:28 +00:00
Bar,
}
fn main() {
let opt = Opt::parse();
2018-04-09 09:14:28 +00:00
println!("{:?}", opt);
}