Compare commits
9 commits
dc0cdcfbc0
...
9e56cc9f25
Author | SHA1 | Date | |
---|---|---|---|
9e56cc9f25 | |||
b6147ca7f2 | |||
4af705f372 | |||
31730ed6cd | |||
365061837c | |||
3f6d9223d5 | |||
289a06a228 | |||
8b16296d5e | |||
f091f19a55 |
40 changed files with 236 additions and 68 deletions
69
Cargo.lock
generated
69
Cargo.lock
generated
|
@ -3,12 +3,25 @@
|
|||
version = 3
|
||||
|
||||
[[package]]
|
||||
name = "adventofcode2022"
|
||||
version = "2022.1.0"
|
||||
name = "aoc"
|
||||
version = "0.0.1"
|
||||
|
||||
[[package]]
|
||||
name = "aoc22"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"aoc",
|
||||
"clap",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "aoc22-gdrop"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"aoc",
|
||||
"gumdrop",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
|
@ -17,9 +30,9 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
|||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.0.77"
|
||||
version = "1.0.78"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e9f73505338f7d905b19d18738976aae232eb46b8efc15554ffc56deb5d9ebe4"
|
||||
checksum = "a20104e2335ce8a659d6dd92a51a767a0c062599c73b343fd152cb401e828c3d"
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
|
@ -79,6 +92,26 @@ dependencies = [
|
|||
"libc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5bc700f989d2f6f0248546222d9b4258f5b02a171a431f8285a81c08142629e3"
|
||||
dependencies = [
|
||||
"gumdrop_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "gumdrop_derive"
|
||||
version = "0.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "729f9bd3449d77e7831a18abfb7ba2f99ee813dfd15b8c2167c9a54ba20aa99d"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "heck"
|
||||
version = "0.4.0"
|
||||
|
@ -118,15 +151,15 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.137"
|
||||
version = "0.2.138"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fc7fcc620a3bff7cdd7a365be3376c97191aeaccc2a603e600951e452615bf89"
|
||||
checksum = "db6d7e329c562c5dfab7a46a2afabc8b987ab9a4834c9d1ca04dc54c1546cef8"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.1.3"
|
||||
version = "0.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f9f08d8963a6c613f4b1a78f4f4a4dbfadf8e6545b2d72861731e4858b8b47f"
|
||||
checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4"
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
|
@ -166,27 +199,27 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
version = "1.0.49"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5ea3d908b0e36316caf9e9e2c4625cdde190a7e6f440d794667ed17a1855e725"
|
||||
checksum = "57a8eca9f9c4ffde41714334dee777596264c7825420f521abc92b5b5deb63a5"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.21"
|
||||
version = "1.0.23"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbe448f377a7d6961e30f5955f9b8d106c3f5e449d493ee1b125c1d43c2b5179"
|
||||
checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "0.36.4"
|
||||
version = "0.36.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cb93e85278e08bb5788653183213d3a60fc242b10cb9be96586f5a73dcb67c23"
|
||||
checksum = "a3807b5d10909833d3e9acd1eb5fb988f79376ff10fce42937de71a449c4c588"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
|
@ -204,9 +237,9 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623"
|
|||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "1.0.105"
|
||||
version = "1.0.107"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "60b9b43d45702de4c839cb9b51d9f529c5dd26a4aff255b42b1ebc03e88ee908"
|
||||
checksum = "1f4064b5b16e03ae50984a5a8ed5d4f8803e6bc1fd170a3cda91a1be4b18e3f5"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
|
@ -224,9 +257,9 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.5"
|
||||
version = "1.0.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6ceab39d59e4c9499d4e5a8ee0e2735b891bb7308ac83dfb4e80cad195c9f6f3"
|
||||
checksum = "84a22b9f218b40614adcb3f4ff08b703773ad44fa9423e4e0d346d5db86e4ebc"
|
||||
|
||||
[[package]]
|
||||
name = "version_check"
|
||||
|
|
14
Cargo.toml
14
Cargo.toml
|
@ -1,8 +1,6 @@
|
|||
[package]
|
||||
name = "adventofcode2022"
|
||||
version = "2022.1.0"
|
||||
edition = "2021"
|
||||
|
||||
|
||||
[dependencies]
|
||||
clap = { version = "4.0.29", features = ["derive"] }
|
||||
[workspace]
|
||||
members = [
|
||||
"aoc22",
|
||||
"aoc22-gdrop",
|
||||
"aoc"
|
||||
]
|
||||
|
|
7
aoc/Cargo.toml
Normal file
7
aoc/Cargo.toml
Normal file
|
@ -0,0 +1,7 @@
|
|||
[package]
|
||||
name = "aoc"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
authors = ["Leo Drachenfeuer <leo.drachenfeuer@m-spezial.de>"]
|
||||
|
||||
[dependencies]
|
4
aoc/src/lib.rs
Normal file
4
aoc/src/lib.rs
Normal file
|
@ -0,0 +1,4 @@
|
|||
pub mod year2022;
|
||||
pub mod util;
|
||||
|
||||
pub use year2022::*;
|
35
aoc/src/year2022/mod.rs
Normal file
35
aoc/src/year2022/mod.rs
Normal file
|
@ -0,0 +1,35 @@
|
|||
mod day001;
|
||||
mod day002;
|
||||
mod day003;
|
||||
mod day004;
|
||||
mod day005;
|
||||
mod day006;
|
||||
mod day007;
|
||||
mod day008;
|
||||
mod day009;
|
||||
//mod day010;
|
||||
//mod day011;
|
||||
//mod day012;
|
||||
//mod day013;
|
||||
//mod day014;
|
||||
//mod day015;
|
||||
//mod day016;
|
||||
//mod day017;
|
||||
//mod day018;
|
||||
//mod day019;
|
||||
//mod day020;
|
||||
//mod day021;
|
||||
//mod day022;
|
||||
//mod day023;
|
||||
//mod day024;
|
||||
//mod day025;
|
||||
|
||||
pub use day001::*;
|
||||
pub use day002::*;
|
||||
pub use day003::*;
|
||||
pub use day004::*;
|
||||
pub use day005::*;
|
||||
pub use day006::*;
|
||||
pub use day007::*;
|
||||
pub use day008::*;
|
||||
pub use day009::*;
|
9
aoc22-gdrop/Cargo.toml
Normal file
9
aoc22-gdrop/Cargo.toml
Normal file
|
@ -0,0 +1,9 @@
|
|||
[package]
|
||||
name = "aoc22-gdrop"
|
||||
version = "0.0.1"
|
||||
edition = "2021"
|
||||
authors = ["Leo Drachenfeuer <leo.drachenfeuer@m-spezial.de>"]
|
||||
|
||||
[dependencies]
|
||||
gumdrop = "0.8"
|
||||
aoc = {path= "../aoc"}
|
90
aoc22-gdrop/src/cli/mod.rs
Normal file
90
aoc22-gdrop/src/cli/mod.rs
Normal file
|
@ -0,0 +1,90 @@
|
|||
use aoc::*;
|
||||
use gumdrop::Options;
|
||||
//use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
pub struct AdventOfCode2022 {
|
||||
// Options here can be accepted with any command (or none at all),
|
||||
// but they must come before the command name.
|
||||
#[options(help = "print help message")]
|
||||
help: bool,
|
||||
#[options(help = "be verbose")]
|
||||
verbose: bool,
|
||||
|
||||
// The `command` option will delegate option parsing to the command type,
|
||||
// starting at the first free argument.
|
||||
#[options(command)]
|
||||
command: Option<Commands>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
pub enum Commands {
|
||||
#[options(name = "day001", help = "Solution for the first day")]
|
||||
Day001(Day001Options),
|
||||
#[options(name = "day002", help = "Solution for the second day")]
|
||||
Day002(BasicOptions2),
|
||||
#[options(name = "day003", help = "Solution for day 03")]
|
||||
Day003(BasicOptions),
|
||||
#[options(name = "day004", help = "Solution for day 04")]
|
||||
Day004(BasicOptions),
|
||||
#[options(name = "day005", help = "Solution for day 05")]
|
||||
Day005(BasicOptions),
|
||||
#[options(name = "day006", help = "Solution for day 06")]
|
||||
Day006(BasicOptions),
|
||||
#[options(name = "day007", help = "Solution for day 07")]
|
||||
Day007(BasicOptions),
|
||||
#[options(name = "day008", help = "Solution for day 08")]
|
||||
Day008(BasicOptions),
|
||||
}
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
pub struct BasicOptions {
|
||||
#[options(free, help = "file with input data")]
|
||||
file: Option<PathBuf>,
|
||||
#[options(help = "use alternative subfunction for part2")]
|
||||
alt: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
pub struct BasicOptions2 {
|
||||
#[options(free, help = "file with input data")]
|
||||
file: Option<PathBuf>,
|
||||
#[options(help = "use alternative subfunction for part2")]
|
||||
alt: bool,
|
||||
#[options(help = "switch between different implentations")]
|
||||
mode: u8,
|
||||
}
|
||||
|
||||
#[derive(Debug, Options)]
|
||||
pub struct Day001Options {
|
||||
#[options(free, help = "file with input data")]
|
||||
file: Option<PathBuf>,
|
||||
#[options(help = "use alternative subfunction for part2", default = "1")]
|
||||
top: i32,
|
||||
#[options(help = "calc the sume of all wanted top positions")]
|
||||
total: bool,
|
||||
}
|
||||
|
||||
pub fn execute_cli() {
|
||||
let aoc2022 = AdventOfCode2022::parse_args_default_or_exit();
|
||||
match aoc2022.command {
|
||||
Some(Commands::Day001(Day001Options { file, top, total })) => {
|
||||
Day001Options::p
|
||||
subcmd_day001(&file, &top, &total)
|
||||
},
|
||||
Some(Commands::Day002(BasicOptions2 { file, alt, mode })) => match mode {
|
||||
0 => subcmd_day002(&file, &alt),
|
||||
1 => subcmd_day002_op(&file, &alt),
|
||||
2 => subcmd_day002_iter(&file, &alt),
|
||||
_ => panic!(),
|
||||
},
|
||||
Some(Commands::Day003(BasicOptions { file, alt })) => subcmd_day003(&file, &alt),
|
||||
Some(Commands::Day004(BasicOptions { file, alt })) => subcmd_day004(&file, &alt),
|
||||
Some(Commands::Day005(BasicOptions { file, alt })) => subcmd_day005(&file, &alt),
|
||||
Some(Commands::Day006(BasicOptions { file, alt })) => subcmd_day006(&file, &alt),
|
||||
Some(Commands::Day007(BasicOptions { file, alt })) => subcmd_day007(&file, &alt),
|
||||
Some(Commands::Day008(BasicOptions { file, alt })) => subcmd_day008(&file, &alt),
|
||||
None => unreachable!(),
|
||||
}
|
||||
}
|
10
aoc22-gdrop/src/main.rs
Normal file
10
aoc22-gdrop/src/main.rs
Normal file
|
@ -0,0 +1,10 @@
|
|||
mod cli;
|
||||
use std::env;
|
||||
use cli::execute_cli;
|
||||
|
||||
fn main() {
|
||||
execute_cli();
|
||||
for argument in env::args() {
|
||||
println!("{argument}");
|
||||
}
|
||||
}
|
10
aoc22/Cargo.toml
Normal file
10
aoc22/Cargo.toml
Normal 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"}
|
|
@ -1,13 +1,5 @@
|
|||
mod commands;
|
||||
use clap::{arg, Parser, Subcommand};
|
||||
use commands::day001::*;
|
||||
use commands::day002::*;
|
||||
use commands::day003::*;
|
||||
use commands::day004::*;
|
||||
use commands::day005::*;
|
||||
use commands::day006::*;
|
||||
use commands::day007::*;
|
||||
use commands::day008::*;
|
||||
use aoc::*;
|
||||
//use std::ffi::OsString;
|
||||
use std::path::PathBuf;
|
||||
|
11
aoc22/src/main.rs
Normal file
11
aoc22/src/main.rs
Normal 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}");
|
||||
}
|
||||
}
|
2
notes.md
Normal file
2
notes.md
Normal file
|
@ -0,0 +1,2 @@
|
|||
clap is the best availiable arg parser at the moment for rust but clap comes with the tradeoff of a size overhead for the executalble.
|
||||
The overhead is around 550kb
|
|
@ -1,25 +0,0 @@
|
|||
pub mod day001;
|
||||
pub mod day002;
|
||||
pub mod day003;
|
||||
pub mod day004;
|
||||
pub mod day005;
|
||||
pub mod day006;
|
||||
pub mod day007;
|
||||
pub mod day008;
|
||||
pub mod day009;
|
||||
//pub mod day010;
|
||||
//pub mod day011;
|
||||
//pub mod day012;
|
||||
//pub mod day013;
|
||||
//pub mod day014;
|
||||
//pub mod day015;
|
||||
//pub mod day016;
|
||||
//pub mod day017;
|
||||
//pub mod day018;
|
||||
//pub mod day019;
|
||||
//pub mod day020;
|
||||
//pub mod day021;
|
||||
//pub mod day022;
|
||||
//pub mod day023;
|
||||
//pub mod day024;
|
||||
//pub mod day025;
|
|
@ -1,8 +0,0 @@
|
|||
pub mod util;
|
||||
mod cli;
|
||||
|
||||
use cli::execute_cli;
|
||||
|
||||
fn main() {
|
||||
execute_cli();
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue