Matthew Maurer | 32e7669 | 2020-06-02 11:15:15 -0700 | [diff] [blame] | 1 | //! How to assign some aliases to subcommands |
| 2 | |
| 3 | use structopt::clap::AppSettings; |
| 4 | use structopt::StructOpt; |
| 5 | |
| 6 | #[derive(StructOpt, Debug)] |
| 7 | // https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands |
| 8 | #[structopt(setting = AppSettings::InferSubcommands)] |
| 9 | enum Opt { |
| 10 | // https://docs.rs/clap/2/clap/struct.App.html#method.alias |
| 11 | #[structopt(alias = "foobar")] |
| 12 | Foo, |
| 13 | // https://docs.rs/clap/2/clap/struct.App.html#method.aliases |
| 14 | #[structopt(aliases = &["baz", "fizz"])] |
| 15 | Bar, |
| 16 | } |
| 17 | |
| 18 | fn main() { |
| 19 | let opt = Opt::from_args(); |
| 20 | println!("{:?}", opt); |
| 21 | } |