From 7b9676bcf8fcfe794478cc4ff6d9598b67fc8780 Mon Sep 17 00:00:00 2001 From: Jack Kinsey Date: Wed, 4 Dec 2024 22:55:11 -0500 Subject: [PATCH] Add support for running every day --- src/main.rs | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index ca144b9..ffc622c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -56,14 +56,18 @@ const DAYS: [(Part, Part); 4] = [ fn main() { let args: Vec = std::env::args().collect(); - let day: usize = args - .get(1) - .expect("Please provide a day.") - .parse() - .expect("The day should be a number."); - if day < 1 || day > DAYS.len() { - panic!("That day hasn't been implemented yet!"); + let arg = args.get(1).expect("Please provide a day."); + if arg == "all" { + for day in DAYS { + day.0(); + day.1(); + } + } else { + let day: usize = arg.parse().expect("The day should be a number."); + if day < 1 || day > DAYS.len() { + panic!("That day hasn't been implemented yet!"); + } + DAYS[day - 1].0(); + DAYS[day - 1].1(); } - DAYS[day - 1].0(); - DAYS[day - 1].1(); } -- 2.38.5