use anyhow::{anyhow, Result};
use crate::solution::Solvable;
pub struct Aoc {
pub allow_download: bool,
pub year: u64,
pub solutions: &'static [&'static dyn Solvable],
}
pub fn aoc_main(aoc: Aoc) -> Result<()> {
println!("AOC {}", aoc.year);
let mut day: Option<u8> = None;
if let Some(arg) = std::env::args().nth(1) {
if let Ok(d) = arg.parse() {
day = Some(d);
} else {
return Err(anyhow!("Specify a number to only run the solutions for that specific day. Otherwise all solutions are executed."));
}
}
for solution in aoc.solutions {
if let Some(day) = day {
if solution.day() != day {
continue;
}
}
solution.run(&aoc)?
}
Ok(())
}