diff options
Diffstat (limited to 'CLI')
| -rw-r--r-- | CLI/rust/src/game_of_life.rs | 69 | ||||
| -rw-r--r-- | CLI/rust/src/main.rs | 5 |
2 files changed, 73 insertions, 1 deletions
diff --git a/CLI/rust/src/game_of_life.rs b/CLI/rust/src/game_of_life.rs new file mode 100644 index 0000000..fffaa42 --- /dev/null +++ b/CLI/rust/src/game_of_life.rs @@ -0,0 +1,69 @@ +use clap::{crate_authors, crate_version, App, Arg, ArgMatches, Error}; + +/// Define the Clap CLI for running Game of Life simulation +/// +/// Using Clap to define the available options that can be used with game of life +pub(crate) fn options() -> Result<ArgMatches, Error> { + let matches = App::new("Game of Life") + .author(crate_authors!()) + .version(crate_version!()) + .arg( + Arg::new("seed") + .about("Specify the seed number to use as an initial state [default: random]") + .takes_value(true) + .long("seed") + .short('s') + .conflicts_with("input") + .display_order(0) + ) + .arg( + Arg::new("input") + .about("Specify the path/URL for the file to use as an initial state. (used instead of seed)") + .takes_value(true) + .long("input") + .short('i') + .display_order(1) + ) + .arg( + Arg::new("width") + .about("Specify the width of generated universe. [default: terminal width]") + .takes_value(true) + .long("width") + .display_order(2) + ) + .arg( + Arg::new("height") + .about("Specify the width of generated universe. [default: terminal height]") + .takes_value(true) + .long("height") + .display_order(3) + ) + .arg( + Arg::new("live-cell") + .about("Specify the live-cell representation") + .takes_value(true) + .long("live-cell") + .default_value("█") + .display_order(4) + ) + .arg( + Arg::new("dead-cell") + .about("Specify the dead-cell representation") + .takes_value(true) + .long("dead-cell") + .default_value(" ") + .display_order(5) + ) + .arg( + Arg::new("delay") + .about("Specify the introduced delay between each generation") + .takes_value(true) + .short('d') + .long("delay") + .default_value("50") + .display_order(6) + ) + .get_matches(); + + Ok(matches) +} diff --git a/CLI/rust/src/main.rs b/CLI/rust/src/main.rs index e7a11a9..71f81e5 100644 --- a/CLI/rust/src/main.rs +++ b/CLI/rust/src/main.rs @@ -1,3 +1,6 @@ +mod game_of_life; + fn main() { - println!("Hello, world!"); + let matches = game_of_life::options().unwrap_or_else(|e| e.exit()); + println!("{:?}", matches); } |
