rename the clap based version to aoc22 only

This commit is contained in:
Leo Drachenfeuer 2022-12-19 09:25:54 +01:00
parent 4af705f372
commit b6147ca7f2
Signed by: dragonleo
GPG key ID: A8338FC081137CF0
3 changed files with 2 additions and 2 deletions

10
aoc22/Cargo.toml Normal file
View file

@ -0,0 +1,10 @@
[package]
name = "aoc22"
version = "0.0.1"
edition = "2021"
authors = ["Leo Drachenfeuer <leo.drachenfeuer@m-spezial.de>"]
default-run = "aoc22"
[dependencies]
clap = { version = "4.0.29", features = ["derive"] }
aoc = {path= "../aoc"}

93
aoc22/src/cli/mod.rs Normal file
View file

@ -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<PathBuf>,
/// 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<PathBuf>,
#[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<PathBuf>,
#[arg(long)]
alt: bool,
},
/// Solution for day 04
Day004 {
file: Option<PathBuf>,
#[arg(long)]
alt: bool,
},
/// Solution for day 05
Day005 {
file: Option<PathBuf>,
#[arg(long)]
alt: bool,
},
/// Solution for day 06
Day006 {
file: Option<PathBuf>,
#[arg(long)]
alt: bool,
},
/// Solution for day 07
Day007 {
file: Option<PathBuf>,
#[arg(long)]
alt: bool,
},
/// Solution for day 08
Day008 {
file: Option<PathBuf>,
#[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)
}
}

11
aoc22/src/main.rs Normal file
View file

@ -0,0 +1,11 @@
mod cli;
use std::env;
use cli::execute_cli;
fn main() {
execute_cli();
for argument in env::args() {
println!("{argument}");
}
}