From 1e68c2ac05a1249a10e3d3db7396cda2f968bd05 Mon Sep 17 00:00:00 2001 From: Rh4096 Date: Fri, 6 Dec 2024 01:23:51 +0700 Subject: [PATCH] chore: update data --- src/cli.rs | 14 ++++++++++++++ src/utils/macros.rs | 13 +++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/cli.rs create mode 100644 src/utils/macros.rs 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), + } + }; +}