#!/usr/bin/env bash

set -euo pipefail

BATCH="${1:-batch1-3}"
ENV_FILE="${2:-}"
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"

if [[ "${BATCH}" == "help" || "${BATCH}" == "-h" || "${BATCH}" == "--help" ]]; then
  echo "Usage: bash scripts/start_validation.sh <batch> <env-file>"
  echo "Example: bash scripts/start_validation.sh batch1-3 path/to/your.validation.env"
  exit 0
fi

if [[ -z "${ENV_FILE}" ]]; then
  echo "Usage: bash scripts/start_validation.sh <batch> <env-file>"
  echo "Example: bash scripts/start_validation.sh batch1-3 path/to/your.validation.env"
  exit 1
fi

echo ""
echo "== Step 1: Validation Env Check =="
bash "${ROOT_DIR}/scripts/check_validation_env.sh" "${ENV_FILE}" "${BATCH}"

echo ""
echo "== Step 2: Run Validation Batch =="
bash "${ROOT_DIR}/scripts/run_validation_batch.sh" "${BATCH}" "${ENV_FILE}"
