aoc23/new.sh

25 lines
496 B
Bash
Executable File

#! /bin/sh
set -e
if [ "$#" -ne 1 ]; then
echo "Parameter expected: <day>"
exit 1
fi
if [ "$1" == "--help" ]; then
echo "Usage: $0 <dayxx>"
exit 1
fi
if [ -d "$1" ]; then
echo "Error! Directory '$1' already exists! Refusing to recreate."
exit 1
fi
mkdir -p "$1/src"
cp "template00/src/Main.hs" "$1/src/Main.hs"
cp "template00/.gitignore" "$1/.gitignore"
cp "template00/stack.yaml" "$1/stack.yaml"
sed "s/template00/$1/g" "template00/package.yaml" > "$1/package.yaml"