1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
| use clap::{arg, command, Parser};
#[derive(Debug, Parser)] #[command(version, about, long_about = None)] pub struct Ctx { #[arg(short, long, help = "是否删除", default_value_t = true)] pub rm: bool,
#[clap(skip)] pub dir: String,
#[clap(subcommand)] pub sub: Sub,
pub targets: Vec<String>, }
pub struct Sub { #[arg(short, long, help = "数量", default_value = 0)] pub val: u8, }
fn main() { let ctx = Ctx::parse(); println!("{:?}", ctx); }
|