summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-09-12 21:04:38 +0100
committermhsn <mail@mhsn.net>2025-09-12 21:05:00 +0100
commit47d87fb5b6c14acb4918540580702d49ddfdd037 (patch)
treed5a79cd8f0129d9595b175ccb4f935bf1980d1f7 /init
parentc1a41296795d6faeca4811689563293ed936a80e (diff)
downloadaoc-47d87fb5b6c14acb4918540580702d49ddfdd037.tar.gz
aoc-47d87fb5b6c14acb4918540580702d49ddfdd037.zip
clean up init script
Diffstat (limited to 'init')
-rwxr-xr-xinit50
1 files changed, 21 insertions, 29 deletions
diff --git a/init b/init
index 2dd51ad..cf1e395 100755
--- a/init
+++ b/init
@@ -1,46 +1,38 @@
#!/usr/bin/env sh
-usage="usage: init <year> <day>"
+usage="usage: init <year> <day> <language>"
year=${1?$usage}
day=${2?$usage}
+lang=${3?$usage}
# get directory of this script
-script=$(readlink -f "$0")
-script_path=$(dirname "$script")
+script=$(readlink -f $0)
+script_path=$(dirname $script)
aoc_path=$script_path/$year/$day
mkdir --parents $aoc_path
+touch $aoc_path/puzzle.txt
-# Data directory
+# data directory
if [ ! -d $aoc_path/data ]; then
mkdir --parents $aoc_path/data
for f in "test" "aoc"; do
- touch "$aoc_path/puzzle.txt"
- touch "$aoc_path/data/$f.txt"
- echo "silver: ???\ngold: ???" >"$aoc_path/data/$f.ans"
+ touch $aoc_path/data/$f.txt
+ echo "silver: ???\ngold: ???" >$aoc_path/data/$f.ans
done
fi
-# Python
-if [ ! -d $aoc_path/python ]; then
- uv init \
- --vcs none \
- --name "aoc_$year-$day" \
- --no-pin-python \
- --no-readme \
- --description "advent of code $year-$day" \
- "$aoc_path/python"
- cp "$script_path/template/main.py" "$aoc_path/python/main.py"
- echo "*" >"$aoc_path/python/.gitignore"
-fi
-
-# Rust
-if [ ! -d $aoc_path/rust ]; then
- cargo new \
- --vcs none \
- --name "aoc_$year-$day" \
- "$aoc_path/rust"
- cp "$script_path/template/main.rs" "$aoc_path/rust/src/main.rs"
- echo "*" >"$aoc_path/rust/.gitignore"
-fi
+case $lang in
+python)
+ cp $script_path/template/python.py $aoc_path
+ ;;
+rust)
+ cargo new --vcs none --name aoc_$year-$day $aoc_path/rust
+ cp $script_path/template/main.rs $aoc_path/rust/src/main.rs
+ ;;
+*)
+ echo unknown lang: $lang
+ exit 1
+ ;;
+esac