]> aoc.elinar.fr Git - aoc_2024/commitdiff
Règle pour récupérer l’input
authoralex <>
Sun, 8 Dec 2024 07:33:17 +0000 (08:33 +0100)
committeralex <>
Sun, 8 Dec 2024 07:33:17 +0000 (08:33 +0100)
Nécessite un fichier .cookie avec le cookie de session.

.gitignore
Makefile

index 05cc302fbca0a4a1a8b8273d71a3a07941ced1ae..ae5fb861816e99c22a23f0249da1eca117baa24f 100644 (file)
@@ -1,4 +1,6 @@
 Cargo.lock
 /target
 
+.cookie
+
 *.sw*
index 57a988301eb428536c639be684ca68f99359a818..7e9bc591a96fe159e15cf50ece6e48d972000c24 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -8,6 +8,16 @@ new-day%:
                -e "/_ =>/i\        \"$(subst new-,,$@)\" => $(subst new-,,$@)::run(\&input)?," \
                src/main.rs
 
+# Requires a .cookie file
+# do not use leading 0
+#   make input-1
+#   make input-10
+input-%:
+       [ ! -f .cookie ] && echo "Missing .cookie file" && return 1 || true
+       curl -o input/day$$(printf "%02d" $(subst input-,,$@)).txt \
+               -H "Cookie: session=$$(cat .cookie)" \
+               "https://adventofcode.com/2024/day/$(subst input-,,$@)/input"
+
 # run the tests for a specific day
 test-day%:
        cargo test $(subst test-,,$@)::tests -- --nocapture