Skip to content

Commit

Permalink
batman
Browse files Browse the repository at this point in the history
  • Loading branch information
Linkinlog committed Feb 26, 2024
0 parents commit 8f6f223
Show file tree
Hide file tree
Showing 9 changed files with 503 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
day*/
223 changes: 223 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[package]
name = "gen-aoc"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
clap = { version = "4.5.1", features = ["derive"] }
23 changes: 23 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
PROJECT_NAME := gen-aoc

all: build

build:
cargo build

build-release:
cargo build --release

run: build
./target/debug/$(PROJECT_NAME)

run-release: build-release
./target/release/$(PROJECT_NAME)

lint:
cargo clippy

clean:
cargo clean

.PHONY: all build build-release run run-release lint clean
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
## Features

Generates a shiny new project folder for your chosen day of AOC madness
Automates boilerplate code and tests in Go (we're still working on the whole 'multiple languages' thing)


## Usage (it's so easy, even a reindeer could do it)

```bash
./gen-aoc --day <day_number> --lang <lang>
```
```bash
--day: The AOC puzzle you're about to tackle
```
```bash
--lang: Currently only supports go
```
```bash
--fresh: If you want a sparkling clean start, this flag wipes out any existing code
```
## Disclaimer
AOC Bootstrap won't magically solve the puzzles for you (darn!). But it'll give you a head start and maybe a chuckle or two.
Built with laziness and a sprinkle of procrastination
We know you'd rather be coding than setting up projects. Happy Advent of Code! 🎁
49 changes: 49 additions & 0 deletions src/cli.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
use clap::Parser;

#[derive(clap::ValueEnum, Clone, Debug)]
pub enum Langs {
Go,
}

#[derive(Parser)]
pub struct Cli {
/// Day of AoC to get, must be between 1 and 25
#[arg(short, long, default_value = "1")]
day: u32,
/// Language for template
#[arg(short, long, default_value = "go")]
lang: Langs,
/// Sometimes we all need a fresh start, passing this flag will overwrite existing files
#[arg(short, long, default_value = "false")]
fresh: bool,
}

impl Cli {
pub fn new() -> Self {
let args = Cli::parse();
match args.day {
1..=25 => {}
_ => panic!("Day must be between 1 and 25"),
}
Self {
day: args.day,
lang: args.lang,
fresh: args.fresh,
}
}
pub fn day(&self) -> u32 {
self.day
}
pub fn lang(&self) -> Langs {
self.lang.clone()
}
pub fn fresh(&self) -> bool {
self.fresh
}
}

impl Default for Cli {
fn default() -> Self {
Cli::new()
}
}
Loading

0 comments on commit 8f6f223

Please sign in to comment.