aoc2024/scaffold.sh

58 lines
941 B
Bash
Executable File

#!/usr/bin/env bash
name=day-"$1"
if [ -d day-"$name" ]; then
echo "program $name already exists"
exit 1
fi
mkdir -p "$name"/testdata
touch "$name"/makefile
cat <<EOT >> "$name"/makefile
program = $name
GO = go
SRC_DIR := src
BIN_DIR := bin
EXE := \$(BIN_DIR)/\$(program)
.DEFAULT_GOAL := build
.PHONY: fmt vet build bench clean
fmt:
\$(GO) fmt ./...
vet: fmt
\$(GO) vet ./...
build: vet | \$(BIN_DIR)
\$(GO) build -o \$(EXE) ./\$(SRC_DIR)
bench:
\$(GO) test . -test.count=10 -bench=. > benchmark
\$(BIN_DIR):
@mkdir -p \$@
clean:
@rm -rv \$(BIN_DIR)
EOT
cat <<EOT >> "$name"/solution.go
/********************************************************************************
Advent of Code 2024 - $name
********************************************************************************/
package main
func main() {
}
EOT
cd "$name" || exit
go mod init github.com/onyx-and-iris/aoc2024/"$name"