diff --git a/reset.sh b/reset.sh index ddf189c..5acc44f 100755 --- a/reset.sh +++ b/reset.sh @@ -5,6 +5,36 @@ TEMPLATE_REMOTE="git@git.chipperfluff.at:projects/funkyFlaskTest.git" CONFIRM_MODULE="" SELF_PATH="$0" +# === Dependency check === +require() { + if ! command -v "$1" &>/dev/null; then + echo "❗ Missing dependency: $1" + read -rp "👉 Install $1 now? (y/n): " confirm + if [[ "$confirm" =~ ^[Yy]$ ]]; then + if [[ -f /etc/debian_version ]]; then + sudo apt-get update && sudo apt-get install -y "$1" || { + echo "💥 Failed to install $1 via apt-get" + exit 1 + } + elif [[ "$(uname)" == "Darwin" ]]; then + brew install "$1" || { + echo "💥 Failed to install $1 via brew" + exit 1 + } + else + echo "🤷 I don't know how to install $1 on this system." + exit 1 + fi + else + echo "🚫 Cannot continue without $1" + exit 1 + fi + fi +} + +require git +require jq + # === Parse CLI args === while [[ $# -gt 0 ]]; do case "$1" in @@ -15,7 +45,7 @@ while [[ $# -gt 0 ]]; do echo " $TEMPLATE_REMOTE" exit 0 ;; *) - echo "Unknown option: $1" + echo "❌ Unknown option: $1" exit 1 ;; esac shift