summaryrefslogtreecommitdiffstats
path: root/src/main.rs
blob: d5b45166b3b43d07cff0f93d57a4fdb005db8236 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#![allow(clippy::cognitive_complexity)]
#![allow(clippy::missing_const_for_fn)]
#![allow(clippy::similar_names)]
#![allow(clippy::struct_excessive_bools)]
#![allow(clippy::too_many_arguments)]
#![allow(clippy::too_many_lines)]
#![allow(clippy::type_complexity)]
#![allow(clippy::collapsible_else_if)]
#![allow(clippy::collapsible_if)]
#![allow(clippy::comparison_chain)]

#[macro_use]
pub mod regex;

pub mod grid;
pub mod parse;
pub mod prelude;

#[path = "2020/mod.rs"]
mod year2020;
#[path = "2021/mod.rs"]
mod year2021;

#[derive(Debug, structopt::StructOpt)]
#[structopt(about = "Advent of Code")]
enum Opt {
    #[structopt(name = "2020")]
    Year2020 { day: u8, puzzle: u8 },
    #[structopt(name = "2021")]
    Year2021 { day: u8, puzzle: u8 },
}

#[paw::main]
fn main(opt: Opt) {
    let res = match opt {
        Opt::Year2020 { day, puzzle } => crate::year2020::run(day, puzzle),
        Opt::Year2021 { day, puzzle } => crate::year2021::run(day, puzzle),
    };
    match res {
        Ok(answer) => {
            println!("{}", answer);
        }
        Err(e) => {
            eprintln!("{}", e);
            std::process::exit(1);
        }
    }
}