#!/usr/bin/env bash
# Universal URI action dispatcher across paxlet-com, dockuri, heyasa, and wronai.
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$(readlink -f "${BASH_SOURCE[0]}")")" && pwd)"
REPO_DIR="$(cd "${SCRIPT_DIR}/../.." && pwd)"

# HOME is optional: executors and CI run this wrapper without one, and `set -u`
# must not turn a missing HOME into an error. The dockuri checkout is prepended
# only when it exists, and PYTHON_BIN may pin the interpreter (default python3).
HOME_DIR="${HOME:-}"
DOCKURI_DIR="${HOME_DIR:+${HOME_DIR}/github/dockuri/dockuri/python}"
export PYTHONPATH="${DOCKURI_DIR:+${DOCKURI_DIR}:}${REPO_DIR}:${PYTHONPATH:-}"

exec "${PYTHON_BIN:-python3}" -c "import sys; from heyasa.uri import uri_cli; sys.exit(uri_cli())" "$@"
