January 2019
Intermediate to advanced
520 pages
14h 32m
English
Similar to the examples in the previous chapter, we have a parser for arguments. It has the following declaration:
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("FILE") .help("Sets a file name of a database") .takes_value(true), ) .subcommand(SubCommand::with_name(CMD_ADD).about("add user to the table") .arg(Arg::with_name("NAME") .help("Sets the name of a user") .required(true) .index(1)) .arg(Arg::with_name("EMAIL") .help("Sets the email of a user") .required(true) .index(2))) .subcommand(SubCommand::with_name(CMD_LIST).about("prints a list ...Read now
Unlock full access