summaryrefslogtreecommitdiff
path: root/init
diff options
context:
space:
mode:
authormhsn <mail@mhsn.net>2025-04-30 21:40:41 +0100
committermhsn <mail@mhsn.net>2025-04-30 21:40:41 +0100
commit4f9faaa646ba63cb4b6aa29738bbae7a6b4ff132 (patch)
tree8db96109abe69242a8a4fecf638a3b39f4993e20 /init
parent07b66483fbb762209d645b5aa406145b9ede0b2c (diff)
downloadaoc-4f9faaa646ba63cb4b6aa29738bbae7a6b4ff132.tar.gz
aoc-4f9faaa646ba63cb4b6aa29738bbae7a6b4ff132.zip
clean up shell scripts
Diffstat (limited to 'init')
-rwxr-xr-xinit23
1 files changed, 17 insertions, 6 deletions
diff --git a/init b/init
index b5ed7ac..2dd51ad 100755
--- a/init
+++ b/init
@@ -1,17 +1,19 @@
#!/usr/bin/env sh
-year=$1
-day=$2
+usage="usage: init <year> <day>"
+year=${1?$usage}
+day=${2?$usage}
+# get directory of this script
script=$(readlink -f "$0")
script_path=$(dirname "$script")
-aoc_path=$script_path/$1/$2
+aoc_path=$script_path/$year/$day
mkdir --parents $aoc_path
+# Data directory
if [ ! -d $aoc_path/data ]; then
- # Data directory
mkdir --parents $aoc_path/data
for f in "test" "aoc"; do
touch "$aoc_path/puzzle.txt"
@@ -22,14 +24,23 @@ fi
# Python
if [ ! -d $aoc_path/python ]; then
- mkdir --parents $aoc_path/python
+ 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 "$aoc_path/rust" --vcs none --name "aoc_$year-$day"
+ 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