test around with multi bin projects
This commit is contained in:
parent
8b16296d5e
commit
289a06a228
6 changed files with 137 additions and 4 deletions
12
Cargo.lock
generated
12
Cargo.lock
generated
|
@ -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"
|
||||
|
|
18
Cargo.toml
18
Cargo.toml
|
@ -1,6 +1,20 @@
|
|||
[workspace]
|
||||
[package]
|
||||
name = "adventofcode"
|
||||
version = "2022.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[workspace]
|
||||
members = [
|
||||
"aoc22-clap",
|
||||
"aoc22-gdrop",
|
||||
"aoc"
|
||||
]
|
||||
]
|
||||
|
||||
[[bin]]
|
||||
name = "aoc22-clap"
|
||||
path = "aoc22-clap"
|
||||
|
||||
[[bin]]
|
||||
name = "aoc22-gdrop"
|
||||
path = "aoc22-gdrop"
|
|
@ -3,7 +3,6 @@ name = "aoc22-clap"
|
|||
version = "2022.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.29", features = ["derive"] }
|
||||
aoc = {path= "../aoc"}
|
||||
aoc = {path= "../aoc"}
|
||||
|
|
8
aoc22-gdrop/Cargo.toml
Normal file
8
aoc22-gdrop/Cargo.toml
Normal file
|
@ -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"}
|
93
aoc22-gdrop/src/cli/mod.rs
Normal file
93
aoc22-gdrop/src/cli/mod.rs
Normal 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)
|
||||
}
|
||||
}
|
7
aoc22-gdrop/src/main.rs
Normal file
7
aoc22-gdrop/src/main.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
mod cli;
|
||||
|
||||
use cli::execute_cli;
|
||||
|
||||
fn main() {
|
||||
execute_cli();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue