2022-03-03 18:32:29 +00:00
|
|
|
// Note: this requires the `cargo` feature
|
|
|
|
|
2022-02-15 14:33:38 +00:00
|
|
|
use clap::{arg, command, Command};
|
2021-11-30 18:30:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
2022-02-15 14:33:38 +00:00
|
|
|
let matches = command!()
|
2022-02-10 17:51:40 +00:00
|
|
|
.propagate_version(true)
|
2022-02-11 20:40:04 +00:00
|
|
|
.subcommand_required(true)
|
|
|
|
.arg_required_else_help(true)
|
2021-11-30 18:30:19 +00:00
|
|
|
.subcommand(
|
2022-02-12 03:48:29 +00:00
|
|
|
Command::new("add")
|
2021-11-30 18:30:19 +00:00
|
|
|
.about("Adds files to myapp")
|
|
|
|
.arg(arg!([NAME])),
|
|
|
|
)
|
|
|
|
.get_matches();
|
|
|
|
|
|
|
|
match matches.subcommand() {
|
|
|
|
Some(("add", sub_matches)) => println!(
|
|
|
|
"'myapp add' was used, name is: {:?}",
|
|
|
|
sub_matches.value_of("NAME")
|
|
|
|
),
|
2022-02-11 20:40:04 +00:00
|
|
|
_ => unreachable!("Exhausted list of subcommands and subcommand_required prevents `None`"),
|
2021-11-30 18:30:19 +00:00
|
|
|
}
|
|
|
|
}
|