2015-04-28 01:10:37 -04:00
|
|
|
extern crate pirate;
|
|
|
|
|
2015-06-16 14:28:14 -04:00
|
|
|
use std::env;
|
|
|
|
|
|
|
|
use pirate::{matches, vars};
|
2015-04-28 01:10:37 -04:00
|
|
|
|
|
|
|
fn main() {
|
2015-06-16 14:28:14 -04:00
|
|
|
let env_args: Vec<String> = env::args().collect();
|
|
|
|
let opts = vec!["o/opt(An option)", "a(Argument):"];
|
|
|
|
let mut vars = vars("A Test Program", &opts).unwrap();
|
|
|
|
|
|
|
|
let matches = match matches(&mut vars, &env_args) {
|
2015-06-10 18:14:11 +00:00
|
|
|
Ok(m) => m,
|
2015-06-16 14:28:14 -04:00
|
|
|
Err(why) => panic!("An error occurred: {}", why)
|
2015-04-28 01:10:37 -04:00
|
|
|
};
|
2015-06-16 14:28:14 -04:00
|
|
|
|
|
|
|
if matches.has_match("a") {
|
|
|
|
let m = matches.get("a").unwrap();
|
|
|
|
println!("{}", m);
|
|
|
|
}
|
|
|
|
|
|
|
|
match matches.get("opt") {
|
|
|
|
Some(_) => println!("Opt was passed to the program"),
|
|
|
|
None => println!("Opt was not passed to the program")
|
2015-04-28 01:10:37 -04:00
|
|
|
}
|
|
|
|
}
|