2021-11-30 18:30:19 +00:00
|
|
|
use clap::{app_from_crate, arg};
|
2015-03-29 01:19:51 +00:00
|
|
|
|
|
|
|
fn main() {
|
2021-11-30 18:30:19 +00:00
|
|
|
let matches = app_from_crate!()
|
2018-01-25 04:05:05 +00:00
|
|
|
.arg(
|
2021-11-30 18:30:19 +00:00
|
|
|
arg!(<MODE>)
|
2021-11-18 16:17:15 +00:00
|
|
|
.help("What mode to run the program in")
|
2021-11-30 18:30:19 +00:00
|
|
|
.possible_values(["fast", "slow"]),
|
2018-01-25 04:05:05 +00:00
|
|
|
)
|
|
|
|
.get_matches();
|
2015-03-29 01:19:51 +00:00
|
|
|
|
|
|
|
// Note, it's safe to call unwrap() because the arg is required
|
2021-11-12 14:42:25 +00:00
|
|
|
match matches
|
|
|
|
.value_of("MODE")
|
|
|
|
.expect("'MODE' is required and parsing will fail if its missing")
|
|
|
|
{
|
2015-03-29 01:19:51 +00:00
|
|
|
"fast" => {
|
2021-11-12 01:06:50 +00:00
|
|
|
println!("Hare");
|
2018-01-25 04:05:05 +00:00
|
|
|
}
|
2015-03-29 01:19:51 +00:00
|
|
|
"slow" => {
|
2021-11-12 01:06:50 +00:00
|
|
|
println!("Tortoise");
|
2018-01-25 04:05:05 +00:00
|
|
|
}
|
|
|
|
_ => unreachable!(),
|
2015-03-29 01:19:51 +00:00
|
|
|
}
|
2016-01-27 22:22:34 +00:00
|
|
|
}
|