forked from LeMoonStar/AoC24
💬 Updated CLI for 2024
This commit is contained in:
parent
c43f3d37ee
commit
73760fbec4
2 changed files with 1677 additions and 6 deletions
1671
Cargo.lock
generated
Normal file
1671
Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
12
src/main.rs
12
src/main.rs
|
@ -17,9 +17,9 @@ use std::sync::Arc;
|
||||||
// TODO: Rewrite CLI and update Clap
|
// TODO: Rewrite CLI and update Clap
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let matches = App::new("Advent Of Code 2023")
|
let matches = App::new("Advent Of Code 2024")
|
||||||
.author("LeMoonStar <webmaster@unitcore.de>")
|
.author("LeMoonStar <webmaster@unitcore.de>")
|
||||||
.about("My Advent Of Code 2023 solutions.")
|
.about("My Advent Of Code 2024 solutions.")
|
||||||
.setting(AppSettings::SubcommandRequiredElseHelp)
|
.setting(AppSettings::SubcommandRequiredElseHelp)
|
||||||
.arg(
|
.arg(
|
||||||
Arg::with_name("day")
|
Arg::with_name("day")
|
||||||
|
@ -200,10 +200,10 @@ fn download_input(day: u8, session: &String) -> Result<String, reqwest::Error> {
|
||||||
.build()?;
|
.build()?;
|
||||||
|
|
||||||
let response = client
|
let response = client
|
||||||
.get(format!("https://adventofcode.com/2023/day/{}/input", day))
|
.get(format!("https://adventofcode.com/2024/day/{}/input", day))
|
||||||
.header(
|
.header(
|
||||||
USER_AGENT,
|
USER_AGENT,
|
||||||
"https://github.com/LeMoonStar/AoC23 aoc23@unitcore.de",
|
"https://github.com/LeMoonStar/AoC24 aoc24@unitcore.de",
|
||||||
)
|
)
|
||||||
.send()?;
|
.send()?;
|
||||||
|
|
||||||
|
@ -215,7 +215,7 @@ fn download_input(day: u8, session: &String) -> Result<String, reqwest::Error> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_auto_input(day: u8, session: Option<&String>, cache: bool) -> String {
|
fn get_auto_input(day: u8, session: Option<&String>, cache: bool) -> String {
|
||||||
let cache_str = &format!("./.aoc23_cache/input{:02}.txt", day);
|
let cache_str = &format!("./.aoc24_cache/input{:02}.txt", day);
|
||||||
let cache_path: &Path = Path::new(cache_str);
|
let cache_path: &Path = Path::new(cache_str);
|
||||||
match cache {
|
match cache {
|
||||||
true => match fs::read_to_string(cache_path) {
|
true => match fs::read_to_string(cache_path) {
|
||||||
|
@ -224,7 +224,7 @@ fn get_auto_input(day: u8, session: Option<&String>, cache: bool) -> String {
|
||||||
if let Some(session) = session {
|
if let Some(session) = session {
|
||||||
match download_input(day, session) {
|
match download_input(day, session) {
|
||||||
Ok(input) => {
|
Ok(input) => {
|
||||||
let _ = fs::create_dir(Path::new("./.aoc23_cache"));
|
let _ = fs::create_dir(Path::new("./.aoc24_cache"));
|
||||||
match fs::write(cache_path, &input) {
|
match fs::write(cache_path, &input) {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue