#!/usr/bin/env bash
# Enrichment helper (Adult Empire enricher)
# Usage:
#   ./scripts/enrich.sh all
#   ./scripts/enrich.sh performers
#   ./scripts/enrich.sh scenes
# Optional flags are passed through after the subcommand, e.g.:
#   ./scripts/enrich.sh performers --start-id 100 --limit 50

set -euo pipefail

cmd="${1:-}"
shift || true

repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

run() {
  echo "▶ $*"
  if [[ -x "$repo_root/goondex" ]]; then
    exec "$repo_root/goondex" "$@"
  elif [[ -x "$repo_root/bin/goondex" ]]; then
    exec "$repo_root/bin/goondex" "$@"
  else
    echo "goondex binary not found. Build it first with: go build -o bin/goondex ./cmd/goondex" >&2
    exit 1
  fi
}

case "$cmd" in
  all)
    run enrich all-performers "$@"
    ;;
  performers|performer)
    run enrich all-performers "$@"
    ;;
  scenes|scene)
    run enrich all-scenes "$@"
    ;;
  *)
    cat <<'EOF' >&2
Usage: ./scripts/enrich.sh {all|performers|scenes} [flags]

Examples:
  ./scripts/enrich.sh all
  ./scripts/enrich.sh performers --start-id 100 --limit 50
  ./scripts/enrich.sh scenes --start-id 200
EOF
    exit 1
    ;;
esac
