advent-of-code/2023/new_day

26 lines
683 B
Text
Raw Normal View History

2023-12-02 12:25:29 +01:00
#!/bin/bash
set -euxo pipefail
if [[ $# -ne 2 ]]; then
>&2 echo "Usage: $0 <number> <name>"
exit 2
fi
filename=day$1_$2
2023-12-02 13:57:21 +01:00
cp template.go ${filename}.go
cp template_test.go ${filename}_test.go
2023-12-02 12:25:29 +01:00
if [ "$(uname -s)" == "Linux" ]; then
2023-12-02 13:57:21 +01:00
sed -e "s/Dxx/Day$1/g" -i ./${filename}.go
sed -e "s/Dxx/Day$1/g" -i ./${filename}_test.go
sed -e "s/dayxx/day$1/g" -i ./${filename}_test.go
2023-12-02 12:25:29 +01:00
else
2023-12-02 13:57:21 +01:00
sed -e "s/Dxx/Day$1/g" -i "" ./${filename}.go
sed -e "s/Dxx/Day$1/g" -i "" ./${filename}_test.go
sed -e "s/dayxx/day$1/g" -i "" ./${filename}_test.go
2023-12-02 12:25:29 +01:00
fi
mkdir -p inputs
touch inputs/day$1
touch inputs/day$1_test1
touch inputs/day$1_test2
2023-12-02 13:57:21 +01:00
git add "inputs/day$1*" ${filename}*