clap/examples/21_aliases.rs
Ed Page 7e899cd340 Revert "Deprecate Arg::help in favour of Arg::about"
This reverts commits 24cb8b1..d0abb37 from clap-rs/clap#1840

This is part of #16.  clap-rs/clap#1840 wasn't the right call but we
don't have time to make the decision now, so instead of having one
option and changing it in 4.0, this reverts back to clap2 behavior.
2021-11-18 12:25:49 -06:00

33 lines
1,009 B
Rust

use clap::{App, Arg};
fn main() {
let matches = App::new("MyApp")
.subcommand(
App::new("ls")
.aliases(&["list", "dir"])
.about("Adds files to myapp")
.version("0.1")
.author("Kevin K.")
.arg(
Arg::new("input")
.help("the file to add")
.index(1)
.required(true),
),
)
.get_matches();
// You can also match on a subcommand's name
match matches.subcommand() {
Some(("ls", sub_matches)) => println!(
"'myapp add' was used, input is: {}",
sub_matches
.value_of("input")
.expect("'input' is required and parsing will fail if its missing")
),
None => println!("No subcommand was used"),
_ => println!("Some other subcommand was used"),
}
// Continued program logic goes here...
}