]> localhost Git - adventofcode2024.git/commitdiff
Add support for running every day
authorJack Kinsey <j.jameskinsey@gmail.com>
Thu, 5 Dec 2024 03:55:11 +0000 (22:55 -0500)
committerJack Kinsey <j.jameskinsey@gmail.com>
Thu, 5 Dec 2024 03:55:11 +0000 (22:55 -0500)
src/main.rs

index ca144b900de79ecd655aa5597d16f88b21be662d..ffc622c7bfcc4ae580b204a6e6d8309baaa40b7f 100644 (file)
@@ -56,14 +56,18 @@ const DAYS: [(Part, Part); 4] = [
 
 fn main() {
     let args: Vec<String> = 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();
 }