pirate/tests/main.rs

27 lines
676 B
Rust
Raw Normal View History

2015-04-28 01:10:37 -04:00
extern crate pirate;
use std::env;
use pirate::{matches, vars};
2015-04-28 01:10:37 -04:00
fn main() {
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,
Err(why) => panic!("An error occurred: {}", why)
2015-04-28 01:10:37 -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
}
}