summaryrefslogtreecommitdiffstats
path: root/src/opt.rs
diff options
context:
space:
mode:
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)
+ }
+ }
+ }};
+}