From 79531921f31acc795c801349cfd1508586824683 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sat, 2 Dec 2023 11:34:01 -0800 Subject: [PATCH] Add a way to select each day. --- src/main.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index 1714cf0..9f3dd84 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,4 @@ +use std::env; use std::io; fn get_calibration_digits() -> u32 { @@ -98,5 +99,14 @@ fn get_calibration_digits_alnum() -> u32 { } fn main() { - println!("Sum: {}", get_calibration_digits_alnum()); + let args: Vec = env::args().collect(); + if args.len() < 2 { + println!("Select a day (i.e. day1a, day1b)"); + return; + } + match args[1].as_str() { + "day1a" => println!("Sum: {}", get_calibration_digits()), + "day1b" => println!("Sum: {}", get_calibration_digits_alnum()), + _ => println!("Unrecognized day: {}", args[1]), + } }