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
|
fi
|
||||||
|
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
printf "missing year\n"
|
year=$(date +"%Y")
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
year="$1"
|
year="$1"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
printf "missing day\n"
|
day=$(date +"%_d")
|
||||||
exit 1
|
|
||||||
else
|
else
|
||||||
day="$2"
|
day="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir -p "$(printf "AOC%s/input%s" "$year" "$year")"
|
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 \
|
curl -s https://adventofcode.com/"$year"/day/"$day"/input \
|
||||||
--cookie "session=$session" \
|
--cookie "session=$session" \
|
||||||
-o "$(printf "AOC%s/input%s/day%02d.in" "$year" "$year" "$day")"
|
-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")
|
longDay=$(printf "%02d" "$day")
|
||||||
|
|
||||||
if [ ! -f "$class" ]; then
|
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
|
fi
|
||||||
|
|
Loading…
Reference in New Issue