aoc2024/run.sh
2024-12-02 13:14:49 +00:00

25 lines
523 B
Bash
Executable file

#!/usr/bin/env sh
DIR="$(readlink -f "$(dirname "$0")")"
cd "$DIR" || exit 1
if [ -z "$1" ]
then DAYN="$(date +%d)"
else DAYN="$1"; shift
fi
DAY="$(echo "$DAYN" | sed 's/^0*//')"
DAYP="$(printf "%02d" "$DAY")"
export AOC_INPUT
if [ "$1" = "--" ]
then AOC_INPUT="/dev/stdin"; shift
elif [ "$1" = "-i" ]
then AOC_INPUT="$2"; shift; shift
else
AOC_INPUT="$DIR/input/day$DAYP.txt"
if ! [ -f "$AOC_INPUT" ]
then ./fetch.sh "$DAY" || exit 1
fi
fi
exec gst -g "days/utils.st" "days/day$DAYP.st" < "$AOC_INPUT"