mirror of
https://github.com/clap-rs/clap
synced 2024-12-14 06:42:33 +00:00
20 lines
530 B
Rust
20 lines
530 B
Rust
//! How to assign some aliases to subcommands
|
|
|
|
use clap::{AppSettings, Clap};
|
|
|
|
#[derive(Clap, Debug)]
|
|
// https://docs.rs/clap/2/clap/enum.AppSettings.html#variant.InferSubcommands
|
|
#[clap(setting = AppSettings::InferSubcommands)]
|
|
enum Opt {
|
|
// https://docs.rs/clap/2/clap/struct.App.html#method.alias
|
|
#[clap(alias = "foobar")]
|
|
Foo,
|
|
// https://docs.rs/clap/2/clap/struct.App.html#method.aliases
|
|
#[clap(aliases = &["baz", "fizz"])]
|
|
Bar,
|
|
}
|
|
|
|
fn main() {
|
|
let opt = Opt::parse();
|
|
println!("{:?}", opt);
|
|
}
|