January 2019
Intermediate to advanced
520 pages
14h 32m
English
Since our command supports three subcommands, we have to add them to a clap::App instance:
let matches = App::new(crate_name!()) .version(crate_version!()) .author(crate_authors!()) .about(crate_description!()) .setting(AppSettings::SubcommandRequired) .arg( Arg::with_name("database") .short("d") .long("db") .value_name("ADDR") .help("Sets an address of db connection") .takes_value(true), ) .subcommand(SubCommand::with_name(CMD_ADD).about("add a session") .arg(Arg::with_name("TOKEN") .help("Sets the token of a user") .required(true) .index(1)) .arg(Arg::with_name("UID") .help("Sets the uid of a user") .required(true) .index(2))) .subcommand(SubCommand::with_name(CMD_REMOVE).about("remove a session") .arg(Arg::with_name("TOKEN") ...Read now
Unlock full access