2022-02-15 14:33:38 +00:00
|
|
|
use clap::{arg, command, Command};
|
2021-11-30 18:30:19 +00:00
|
|
|
|
|
|
|
fn main() {
|
2022-07-19 18:29:31 +00:00
|
|
|
let matches = command!() // requires `cargo` feature
|
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: {:?}",
|
2022-05-25 15:46:42 +00:00
|
|
|
sub_matches.get_one::<String>("NAME")
|
2021-11-30 18:30:19 +00:00
|
|
|
),
|
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
|
|
|
}
|
|
|
|
}
|