#!/usr/bin/env bash
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
PYTHON="$REPO_ROOT/venv/bin/python"

if [[ ! -x "$PYTHON" ]]; then
  cat >&2 <<EOF
Missing repo virtualenv Python: $PYTHON

Create/install the project virtual environment first:
  python3 -m venv venv
  ./venv/bin/python -m pip install -r requirements.txt

Then rerun:
  ./scripts/gitea-config-menu
EOF
  exit 1
fi

exec "$PYTHON" "$REPO_ROOT/gitea_config.py" menu "$@"
