1 //! How to assign some aliases to subcommands 2 //! 3 //! Running this example with --help prints this message: 4 //! ----------------------------------------------------- 5 //! structopt 0.3.25 6 //! 7 //! USAGE: 8 //! subcommand_aliases <SUBCOMMAND> 9 //! 10 //! FLAGS: 11 //! -h, --help Prints help information 12 //! -V, --version Prints version information 13 //! 14 //! SUBCOMMANDS: 15 //! bar 16 //! foo 17 //! help Prints this message or the help of the given subcommand(s) 18 //! ----------------------------------------------------- 19 20 use structopt::clap::AppSettings; 21 use structopt::StructOpt; 22 23 #[derive(StructOpt, Debug)] 24 // https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands 25 #[structopt(setting = AppSettings::InferSubcommands)] 26 enum Opt { 27 // https://docs.rs/clap/2/clap/struct.App.html#method.alias 28 #[structopt(alias = "foobar")] 29 Foo, 30 // https://docs.rs/clap/2/clap/struct.App.html#method.aliases 31 #[structopt(aliases = &["baz", "fizz"])] 32 Bar, 33 } 34 main()35fn main() { 36 let opt = Opt::from_args(); 37 println!("{:?}", opt); 38 } 39