default to current day and curl puzzle name from the site
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
8eb033ff4c
commit
ec2cdbda93
10
getday.sh
10
getday.sh
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue