summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/main.rs b/src/main.rs
index c1c7cb2..2dda38f 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,3 +1,5 @@
+use crate::random_tables::RandomTables;
+
mod cli;
mod dice;
mod random_tables;
@@ -7,11 +9,18 @@ fn main() {
match matches.subcommand() {
Some(("roll", sub_matches)) => {
- match dice::roll_formula(sub_matches.get_one::<String>("FORMULA").expect("required")) {
- Some(result) => println!("Rolled: {}", result),
+ let formula = sub_matches.get_one::<String>("FORMULA").expect("required");
+ match dice::roll_formula(formula) {
+ Some(roll_result) => println!("Rolled: {}", roll_result),
None => eprintln!("Error: Invalid roll formula or calculation failed.")
}
}
+ Some(("random", sub_matches)) => {
+ let random_tables = RandomTables::new().unwrap();
+ let table_name = sub_matches.get_one::<String>("TABLE").expect("required");
+ let output_text = random_tables.roll_table(table_name);
+ println!("{}", output_text)
+ }
_ => unreachable!()
}
}