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

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

if [[ -n "${SQLC_BIN:-}" ]]; then
  sqlc_cmd=("$SQLC_BIN")
else
  sqlc_cmd=(go run github.com/sqlc-dev/sqlc/cmd/sqlc@v1.31.1)
fi

exec "${sqlc_cmd[@]}" generate "$@"
