summaryrefslogtreecommitdiffstats
path: root/CLI/rust/src/game_of_life.rs
diff options
context:
space:
mode:
authora14m <[email protected]>2021-04-01 23:35:51 +0200
committera14m <[email protected]>2021-04-01 23:35:51 +0200
commit1a4ff7c28a1dc8ee3e1aa22e8e5941b37e7d1adc (patch)
treea0d66e05ac752abd48585d599b4402ca06475052 /CLI/rust/src/game_of_life.rs
parent7faaaff2ab17a2571117e4ba93aa2139b2ddb376 (diff)
Add CLI Width/Height validations
Diffstat (limited to 'CLI/rust/src/game_of_life.rs')
-rw-r--r--CLI/rust/src/game_of_life.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/CLI/rust/src/game_of_life.rs b/CLI/rust/src/game_of_life.rs
index fffaa42..c854e7f 100644
--- a/CLI/rust/src/game_of_life.rs
+++ b/CLI/rust/src/game_of_life.rs
@@ -1,5 +1,8 @@
use clap::{crate_authors, crate_version, App, Arg, ArgMatches, Error};
+/// Options module for validations and Opts struct
+pub(crate) mod opts;
+
/// 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
@@ -29,6 +32,7 @@ pub(crate) fn options() -> Result<ArgMatches, Error> {
.about("Specify the width of generated universe. [default: terminal width]")
.takes_value(true)
.long("width")
+ .validator(opts::validators::is_fitting_term_width)
.display_order(2)
)
.arg(
@@ -36,6 +40,7 @@ pub(crate) fn options() -> Result<ArgMatches, Error> {
.about("Specify the width of generated universe. [default: terminal height]")
.takes_value(true)
.long("height")
+ .validator(opts::validators::is_fitting_term_height)
.display_order(3)
)
.arg(