-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-day.sh
executable file
·36 lines (28 loc) · 1.03 KB
/
setup-day.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# Based on https://github.com/lucianoq/adventofcode/commit/6469f7bf0bdcb31d50658e63477f503d429ae66b
. .env
YEAR="$1"
DAY="$2"
#create dir
mkdir -p "$YEAR/$DAY"
# download input files
curl --cookie "session=${session}" "https://adventofcode.com/$YEAR/day/$DAY/input" >"$YEAR/$DAY/input" 2>/dev/null
# download assignment
curl --cookie "session=${session}" "https://adventofcode.com/$YEAR/day/$DAY" 2>/dev/null | pup 'article.day-desc' >"$YEAR/$DAY/tmp.html"
lynx -dump "$YEAR/$DAY/tmp.html" -width 80 >"$YEAR/$DAY/assignment"
rm -f "$YEAR/$DAY/tmp.html"
# add skeleton files if they don't already exist
for f in day-skeleton/*;
do
base=$(basename "${f}")
if [ ! -f "${YEAR}/${DAY}/${base}" ];
then
echo "Creating skeleton file ${YEAR}/${DAY}/${base}"
cp -a "day-skeleton/${base}" "${YEAR}/${DAY}/"
fi
done
# Configure new package name
sed -i "s@[email protected]/RoystonS/aoc-go/${YEAR}/${DAY}@" "${YEAR}/${DAY}/go.mod"
# Add the package to the Go workspace
cd "${YEAR}/${DAY}"
go work use .