diff --git a/src/cli.rs b/src/cli.rs new file mode 100644 index 0000000..8f751a2 --- /dev/null +++ b/src/cli.rs @@ -0,0 +1,14 @@ +use std::path::PathBuf; + +use clap::Parser; + +#[derive(Parser, Debug, Clone)] +#[command(version, about, long_about = None)] +#[command(propagate_version = true)] +#[command(rename_all = "kebab-case")] +pub struct AocCli { + #[arg(short, long)] + pub day: u8, + #[arg(short, long, default_value = None)] + pub input: Option, +} diff --git a/src/utils/macros.rs b/src/utils/macros.rs new file mode 100644 index 0000000..87b2851 --- /dev/null +++ b/src/utils/macros.rs @@ -0,0 +1,13 @@ +#[macro_export] +macro_rules! map_solution { + ($cli:ident : $($day:expr => $sol:expr,)+ $(,)?) => { + match $cli .day { + $($day => { + let sol = $sol; + let input = sol.get_input($cli.input.as_deref())?; + println!("\tp1: {}\n\tp2: {}", sol.part_one(&input)?, sol.part_two(&input)?); + },)+ + _ => return Err(Error::UnsupportedDay), + } + }; +}