CLI args to pick mode

This commit is contained in:
Nick Pegg 2025-07-06 12:36:48 -07:00
parent dfdbf72188
commit 6aeda0a22f
3 changed files with 231 additions and 13 deletions

View file

@ -1,6 +1,7 @@
use blackjack::card::Card;
use blackjack::game::{Game, PlayResult, PlayerChoice};
use blackjack::hand::Hand;
use clap::{Parser, ValueEnum};
use console::Term;
use std::env;
use std::fs;
@ -10,9 +11,25 @@ use std::path::{Path, PathBuf};
fn main() {
// TODO: Use anyhow for error handling, get rid of unwraps
// TODO: CLI flags to choose how to play
interactive_play();
// old_man();
let args = Args::parse();
println!("{:?}", args);
match args.mode {
Mode::Interactive => interactive_play(),
Mode::OldMan => old_man(),
}
}
#[derive(ValueEnum, Clone, Debug)]
enum Mode {
Interactive,
OldMan,
}
#[derive(Parser, Debug)]
#[command(version, about)]
struct Args {
#[arg(long, default_value = "interactive")]
mode: Mode,
}
fn interactive_play() {