mirror of
https://github.com/Noratrieb/advent-of-code.git
synced 2026-01-14 17:45:02 +01:00
script
This commit is contained in:
parent
8ffd71c2d1
commit
56f39b5c3c
11 changed files with 120 additions and 5 deletions
27
aoc.sh
Executable file
27
aoc.sh
Executable file
|
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -eu
|
||||
|
||||
function get_cookie {
|
||||
if [ ! -f aoc_cookie ]; then
|
||||
echo "aoc_cookie file not found, cannot download" >&2
|
||||
exit 1
|
||||
fi
|
||||
cat aoc_cookie
|
||||
}
|
||||
|
||||
: "${1:?usage: ./aoc.sh new}"
|
||||
|
||||
case "$1" in
|
||||
new)
|
||||
: "${2:?usage: ./aoc.sh new DAY}"
|
||||
day="$(printf %02d "$2")"
|
||||
cp -r "2023/day00" "2023/day$day"
|
||||
find "2023/day$day" -type f -exec sed -i -e "s/00/$day/g" {} \;
|
||||
|
||||
curl -H "Cookie: $(get_cookie)" "https://adventofcode.com/2023/day/$2/input" -o "2023/day$day/input.txt"
|
||||
;;
|
||||
*)
|
||||
echo "usage: ./aoc.sh new" >&2
|
||||
;;
|
||||
esac
|
||||
Loading…
Add table
Add a link
Reference in a new issue