summaryrefslogtreecommitdiffstats
path: root/src/opt.rs
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2022-12-11 21:59:21 -0500
committerJesse Luehrs <doy@tozt.net>2022-12-11 22:16:30 -0500
commite2d219b331a878bbb3c9dcef9ea4e218b2e3ee06 (patch)
tree93e418011c45cab8d4070d3d33b377a9364f4a27 /src/opt.rs
parent179467096141b7e8f67d63b89fd21e779a564fe6 (diff)
downloadadvent-of-code-e2d219b331a878bbb3c9dcef9ea4e218b2e3ee06.tar.gz
advent-of-code-e2d219b331a878bbb3c9dcef9ea4e218b2e3ee06.zip
refactor
Diffstat (limited to 'src/opt.rs')
-rw-r--r--src/opt.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/src/opt.rs b/src/opt.rs
new file mode 100644
index 0000000..296ea83
--- /dev/null
+++ b/src/opt.rs
@@ -0,0 +1,20 @@
+#[derive(Debug, structopt::StructOpt)]
+#[structopt(about = "Advent of Code")]
+pub struct Opt {
+ pub day: u8,
+ pub puzzle: u8,
+}
+
+#[macro_export]
+macro_rules! day {
+ ($year:expr, $day:expr, $puzzle:expr, $mod:ident) => {{
+ let data = $mod::parse(parse::data($year, $day)?)?;
+ match $puzzle {
+ 1 => println!("{}", $mod::part1(data)?),
+ 2 => println!("{}", $mod::part2(data)?),
+ _ => {
+ panic!("unknown puzzle {} for day {}", $puzzle, $day)
+ }
+ }
+ }};
+}