-
Notifications
You must be signed in to change notification settings - Fork 0
/
prepare_for_day
executable file
·42 lines (31 loc) · 1.15 KB
/
prepare_for_day
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
37
38
39
40
41
42
#!/bin/bash
export TZ=Europe/Sofia
if [ $# -gt 0 ]; then
DAY=$1
else
DAY=$(date +%-d)
echo "No day given, assume the day is the current one: '$DAY' ..."
fi
#####################################################################################################
if [ $# -gt 1 ]; then
YEAR=$2
else
YEAR=$(date +%-Y)
echo "No year given, assume the year is the current one: '$YEAR' ..."
fi
#####################################################################################################
DAYFOLDER="day$DAY";
COOKIE=$(cat cookie);
function elog(){ echo; echo "$(date +%Y_%m_%d__%H_%M_%S) : $1"; }
elog "Script started for day: '$DAY' ...";
elog "Making '$DAYFOLDER/':";
mkdir -p $DAYFOLDER/ ;
elog "Copying _day_template/ to $DAYFOLDER/ :";
rsync -av _day_template/ $DAYFOLDER/ ; rm -rf $DAYFOLDER/input ;
git add -f $DAYFOLDER/ ; git commit -m "Prepare $DAYFOLDER .";
elog "Downloading the input for day $DAY:";
curl -H "cookie: $COOKIE" --output $DAYFOLDER/input https://adventofcode.com/$YEAR/day/$DAY/input ;
git add -f $DAYFOLDER/ ; git commit -m "Download $DAYFOLDER/input ." ;
elog "DONE.";
echo "Now you can:";
echo "jed $DAYFOLDER/solution.php";