#!/usr/bin/env bash
# Usage: source scripts/load-env.sh
# Loads API keys from .env.local (or .env if you prefer) without hardcoding them in scripts.

if [[ "${BASH_SOURCE[0]}" == "$0" ]]; then
  echo "Source this script: source scripts/load-env.sh" >&2
  exit 1
fi

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

if [[ -f "$ROOT/.env.local" ]]; then
  set -a
  source "$ROOT/.env.local"
  set +a
elif [[ -f "$ROOT/.env" ]]; then
  set -a
  source "$ROOT/.env"
  set +a
else
  echo "No .env.local or .env found at $ROOT. Create one with your API keys." >&2
fi
