summaryrefslogtreecommitdiff
path: root/bin/init_year
diff options
context:
space:
mode:
authorcos <cos>2022-12-01 16:14:20 +0000
committercos <cos>2022-12-01 17:27:23 +0000
commit1773627631cc873b6a09098dda1cac14c6ed03fa (patch)
tree13e34a2c0348fe20cf2283321189a59c91641f94 /bin/init_year
parent4a54a0d97a57df6c1525b9bbfcabdf829e44a4d1 (diff)
downloadadventofcode-1773627631cc873b6a09098dda1cac14c6ed03fa.zip
Initial commit of init_year, poke support scripts
Diffstat (limited to 'bin/init_year')
-rwxr-xr-xbin/init_year76
1 files changed, 76 insertions, 0 deletions
diff --git a/bin/init_year b/bin/init_year
new file mode 100755
index 0000000..494c86f
--- /dev/null
+++ b/bin/init_year
@@ -0,0 +1,76 @@
+#!/bin/sh -eu
+
+if [ "${1:-}" ]; then
+ _lang="$1"
+fi
+
+if [ "${2:-}" ]; then
+ _year="$2"
+else
+ _year=$( date +%Y )
+fi
+
+### FUNCTION ##################################################################
+
+rust() {
+ rust_dir="$1"
+
+ (
+ printf '%s\n%s\n' '[workspace]' 'members = ['
+ for day in $( seq 1 25 ); do
+ printf '# "day%02d",\n' "${day}"
+ done
+ echo ']'
+ ) > "${rust_dir}/Cargo.toml"
+
+ unset rust_dir
+}
+
+### MAIN ######################################################################
+
+_dir="$( pwd )/${_year}"
+
+if ! [ -d "${_dir}" ]; then
+ read -p "Create directory '${_dir}'?: " _input
+
+ case "${_input}" in
+ 'y' | 'Y')
+ mkdir "${_dir}"
+ ;;
+ *)
+ echo 'Okay, not doing anything then.'
+ exit 0
+ ;;
+ esac
+ unset _input
+fi
+
+[ "${_lang:-}" ] || read -p "Implementation language for '${_year}'?: " _lang
+
+if ! [ -d "${_dir}/${_lang}" ]; then
+ read -p "Create directory '${_dir}/${_lang}'?: " _input
+ case "${_input}" in
+ 'y' | 'Y')
+ mkdir "${_dir}/${_lang}"
+ ;;
+ *)
+ echo 'Okay, not doing that then.'
+ exit 0
+ ;;
+ esac
+ unset _input
+fi
+
+read -p "Run '${_lang}(\"${_dir}/${_lang}\")'?: " _input
+case "${_input}" in
+ 'y' | 'Y')
+ ${_lang} "${_dir}/${_lang}"
+ ;;
+ *)
+ echo 'Okay, not doing that then.'
+ exit 0
+ ;;
+esac
+unset _input
+
+unset _dir _lang _year