summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cli.rs8
-rw-r--r--src/main.rs12
2 files changed, 18 insertions, 2 deletions
diff --git a/src/cli.rs b/src/cli.rs
index b579ad6..005786b 100644
--- a/src/cli.rs
+++ b/src/cli.rs
@@ -8,12 +8,18 @@ pub fn cli() -> Command {
.subcommand_required(true)
.arg_required_else_help(true)
.allow_external_subcommands(true)
+ .subcommand(Command::new("random")
+ .about("Generates a random something")
+ .args_conflicts_with_subcommands(true)
+ .subcommand(Command::new("henchman")
+ .about("Generates a random henchman")),
+ )
.subcommand(Command::new("roll")
.about("Rolls dice based on a given formula")
.arg(arg!(<FORMULA> "The dice rolling formula"))
.arg_required_else_help(true),
)
- .subcommand(Command::new("random")
+ .subcommand(Command::new("table")
.about("Rolls on a random table")
.arg(arg!(<TABLE> "The name of the table to roll on"))
.arg_required_else_help(true),
diff --git a/src/main.rs b/src/main.rs
index 2dda38f..aa6b3bc 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,6 +8,16 @@ fn main() {
let matches = cli::cli().get_matches();
match matches.subcommand() {
+ Some(("random", sub_matches)) => {
+ // TODO: Do something better than unwrap here.
+ let random_command = sub_matches.subcommand().unwrap();
+ match random_command {
+ ("henchman", _) => {
+ println!("Generating a random henchman...");
+ }
+ _ => unreachable!()
+ }
+ }
Some(("roll", sub_matches)) => {
let formula = sub_matches.get_one::<String>("FORMULA").expect("required");
match dice::roll_formula(formula) {
@@ -15,7 +25,7 @@ fn main() {
None => eprintln!("Error: Invalid roll formula or calculation failed.")
}
}
- Some(("random", sub_matches)) => {
+ Some(("table", 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);