ben
/
aoc
1
0
Fork 0

default to current day and curl puzzle name from the site
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Ben Harris 2022-12-09 18:41:00 -05:00
parent 8eb033ff4c
commit ec2cdbda93
1 changed files with 5 additions and 5 deletions

View File

@ -7,21 +7,21 @@ if [ -z "$session" ]; then
fi
if [ -z "$1" ]; then
printf "missing year\n"
exit 1
year=$(date +"%Y")
else
year="$1"
fi
if [ -z "$2" ]; then
printf "missing day\n"
exit 1
day=$(date +"%_d")
else
day="$2"
fi
mkdir -p "$(printf "AOC%s/input%s" "$year" "$year")"
puzzleName=$(curl -s https://adventofcode.com/"$year"/day/"$day" | sed -nr 's/.*--- Day [[:digit:]]+: (.*) ---.*/\1/p')
curl -s https://adventofcode.com/"$year"/day/"$day"/input \
--cookie "session=$session" \
-o "$(printf "AOC%s/input%s/day%02d.in" "$year" "$year" "$day")"
@ -32,5 +32,5 @@ class=$(printf "AOC%s/Day%02d.cs" "$year" "$day")
longDay=$(printf "%02d" "$day")
if [ ! -f "$class" ]; then
sed -e "s/Q/$day/g" -e "s/XX/$longDay/g" -e "s/YYYY/$year/g" DayXX.cs.txt >"$class"
sed -e "s/Q/$day/g" -e "s/XX/$longDay/g" -e "s/YYYY/$year/g" -e "s/Puzzle Name/$puzzleName/g" DayXX.cs.txt >"$class"
fi