# Based on conventions from https://github.com/github/scripts-to-rule-them-all
# script/bootstrap: Resolve all dependencies that the application requires to
# run.

if ! command -v uv &> /dev/null; then
    echo "uv could not be found. Do you want to install it? (y/n)"
    read -r
    if [[ "$REPLY" =~ ^[Yy]$ ]]; then
        if command -v brew &> /dev/null; then
            brew install uv
        else
            curl -fsSL https://astral.sh/uv/install.sh | sh
        fi
    else
        echo "Please install uv to continue"
        return
    fi
fi

uv venv --allow-existing
source .venv/bin/activate

uv run -m python_githooks

if ! complete -p invoke &>/dev/null; then
    source <(inv --print-completion-script bash)
fi
