diff --git a/Cargo.lock b/Cargo.lock index 12577c3..2d1938a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,10 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "adventofcode" +version = "2022.1.0" + [[package]] name = "aoc" version = "2022.1.0" @@ -14,6 +18,14 @@ dependencies = [ "clap", ] +[[package]] +name = "aoc22-gdrop" +version = "2022.1.0" +dependencies = [ + "aoc", + "clap", +] + [[package]] name = "bitflags" version = "1.3.2" diff --git a/Cargo.toml b/Cargo.toml index 482001c..398943c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,20 @@ -[workspace] +[package] +name = "adventofcode" +version = "2022.1.0" +edition = "2021" + +[workspace] members = [ "aoc22-clap", +"aoc22-gdrop", "aoc" -] \ No newline at end of file +] + +[[bin]] +name = "aoc22-clap" +path = "aoc22-clap" + +[[bin]] +name = "aoc22-gdrop" +path = "aoc22-gdrop" \ No newline at end of file diff --git a/aoc22-clap/Cargo.toml b/aoc22-clap/Cargo.toml index 19afcd9..820019c 100644 --- a/aoc22-clap/Cargo.toml +++ b/aoc22-clap/Cargo.toml @@ -3,7 +3,6 @@ name = "aoc22-clap" version = "2022.1.0" edition = "2021" - [dependencies] clap = { version = "4.0.29", features = ["derive"] } -aoc = {path= "../aoc"} \ No newline at end of file +aoc = {path= "../aoc"} diff --git a/aoc22-gdrop/Cargo.toml b/aoc22-gdrop/Cargo.toml new file mode 100644 index 0000000..2219dee --- /dev/null +++ b/aoc22-gdrop/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "aoc22-gdrop" +version = "2022.1.0" +edition = "2021" + +[dependencies] +clap = { version = "4.0.29", features = ["derive"] } +aoc = {path= "../aoc"} diff --git a/aoc22-gdrop/src/cli/mod.rs b/aoc22-gdrop/src/cli/mod.rs new file mode 100644 index 0000000..462e509 --- /dev/null +++ b/aoc22-gdrop/src/cli/mod.rs @@ -0,0 +1,93 @@ +use clap::{arg, Parser, Subcommand}; +use aoc::*; +//use std::ffi::OsString; +use std::path::PathBuf; + +#[derive(Parser)] +#[command(author, version, about, long_about = None)] +#[command(propagate_version = true)] +pub struct AdventOfCode2022 { + #[command(subcommand)] + command: Commands, + /// makes the commands more verbose + #[arg(short, long)] + verbose: bool, +} + +#[derive(Subcommand)] +pub enum Commands { + /// Solution for the first day + Day001 { + file: Option, + /// option to get more than the biggest value + #[arg(short, long, default_value_t = 1)] + top: i32, + /// calc the sume of all wanted top positions + #[arg(long)] + total: bool, + }, + /// Solution for the second day + Day002 { + file: Option, + #[arg(long)] + alt: bool, + /// select implemetation 0 = nomarl with debug, 1 = only result, 2 iter based + #[arg(short, long, default_value_t = 0)] + mode: u8, + }, + /// Solution for day 03 + Day003 { + file: Option, + #[arg(long)] + alt: bool, + }, + /// Solution for day 04 + Day004 { + file: Option, + #[arg(long)] + alt: bool, + }, + /// Solution for day 05 + Day005 { + file: Option, + #[arg(long)] + alt: bool, + }, + /// Solution for day 06 + Day006 { + file: Option, + #[arg(long)] + alt: bool, + }, + /// Solution for day 07 + Day007 { + file: Option, + #[arg(long)] + alt: bool, + }, + /// Solution for day 08 + Day008 { + file: Option, + #[arg(long)] + alt: bool, + }, +} + +pub fn execute_cli() { + let aoc2022 = AdventOfCode2022::parse(); + match &aoc2022.command { + Commands::Day001 { file, top, total } => subcmd_day001(&file, &top, &total), + Commands::Day002 { file, alt, mode } => match mode { + 0 => subcmd_day002(&file, &alt), + 1 => subcmd_day002_op(&file, &alt), + 2 => subcmd_day002_iter(&file, &alt), + _ => panic!(), + }, + Commands::Day003 { file, alt } => subcmd_day003(&file, &alt), + Commands::Day004 { file, alt } => subcmd_day004(&file, &alt), + Commands::Day005 { file, alt } => subcmd_day005(&file, &alt), + Commands::Day006 { file, alt } => subcmd_day006(&file, &alt), + Commands::Day007 { file, alt } => subcmd_day007(&file, &alt), + Commands::Day008 { file, alt } => subcmd_day008(&file, &alt) + } +} diff --git a/aoc22-gdrop/src/main.rs b/aoc22-gdrop/src/main.rs new file mode 100644 index 0000000..11d70e6 --- /dev/null +++ b/aoc22-gdrop/src/main.rs @@ -0,0 +1,7 @@ +mod cli; + +use cli::execute_cli; + +fn main() { + execute_cli(); +}