about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--aoc2021/getday.sh15
1 files changed, 12 insertions, 3 deletions
diff --git a/aoc2021/getday.sh b/aoc2021/getday.sh
index eb7faa0..e9d8d6a 100644
--- a/aoc2021/getday.sh
+++ b/aoc2021/getday.sh
@@ -5,9 +5,18 @@
 if [ -z "$session" ]; then
   printf "missing session cookie\n"
 fi
+
+if [ -z "$1" ]; then
+  day=$(date +"%e" | xargs)
+else
+  day="$1"
+fi
   
-curl -s https://adventofcode.com/2021/day/"$1"/input \
+curl -s https://adventofcode.com/2021/day/"$day"/input \
   --cookie "session=$session" \
-  -o "$(printf "input/day%02d.in" "$1")"
+  -o "$(printf "input/day%02d.in" "$day")"
 
-sed "s/XX/$1/g" DayXX.cs.txt > "$(printf "Day%02d.cs" "$1")"
+class=$(printf "Day%02d.cs" "$day")
+if [ ! -f "$class" ]; then
+  sed "s/XX/$1/g" DayXX.cs.txt > "$class"
+fi