summaryrefslogtreecommitdiff
path: root/src/main.rs
diff options
context:
space:
mode:
authorDavid Gay <eapoems@riseup.net>2023-09-30 23:14:13 -0400
committerDavid Gay <eapoems@riseup.net>2023-09-30 23:14:13 -0400
commit4e5f2211e0be7d189235bc88b1ca8fef29e77f87 (patch)
treeec03bea631875419ba6614e09f42af5c8a0d3308 /src/main.rs
parentf92a67d5d0010a1c9825acd7b6ec87580b429272 (diff)
Basic CLI
Diffstat (limited to 'src/main.rs')
-rw-r--r--src/main.rs16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs
index 88fa2ab..c3431cd 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,10 +1,16 @@
+mod cli;
mod dice;
fn main() {
- const TEST_FORMULA : &str = "3d6";
- println!("Rolling {}:", TEST_FORMULA);
- match dice::roll_formula(TEST_FORMULA) {
- Some(result) => println!("{}", result),
- None => eprintln!("Error: Invalid roll formula, or die roll otherwise failed.")
+ let matches = cli::cli().get_matches();
+
+ match matches.subcommand() {
+ Some(("roll", sub_matches)) => {
+ match dice::roll_formula(sub_matches.get_one::<String>("FORMULA").expect("required")) {
+ Some(result) => println!("Rolled: {}", result),
+ None => eprintln!("Error: Invalid roll formula or calculation failed.")
+ }
+ }
+ _ => unreachable!()
}
}