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