SHARE
TWEET

Untitled

a guest Jul 12th, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. use clap::{App, Arg, SubCommand};
  2.  
  3. fn main() {
  4.     let blame_beltram = vec!["guilt", "blame", "-w", "beltram"];
  5.     let help = vec!["guilt", "--help"];
  6.     let app = App::new("Guilt")
  7.         .version("1.0")
  8.         .author("John Doe<jdoe@gmail.com>")
  9.         .about("Blames someone")
  10.         .subcommand(
  11.             SubCommand::with_name("blame")
  12.                 .about("Output a blame history")
  13.                 .version("1.3")
  14.                 .author("Maria Doe<mdoe@outlook.com>")
  15.                 .arg(
  16.                     Arg::with_name("who")
  17.                         .short("w")
  18.                         .value_name("WHO")
  19.                         .takes_value(true)
  20.                         .help("Who to blame"),
  21.                 ),
  22.         );
  23.     if let Some(matches) = app
  24.         .clone()
  25.         .get_matches_from(blame_beltram)
  26.         .subcommand_matches("blame")
  27.     {
  28.         println!("Ooops {} I did it again", matches.value_of("who").unwrap());
  29.     }
  30.     println!("--------------------");
  31.     println!("Generated help: ");
  32.     println!("{:?}", app.clone().get_matches_from(help));
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top