#!/usr/bin/env bash
# opensim-api: the API of the engine on the command line (see opensim-api.php). The .env of the engine and ~/.opensimrc are read first
# (see lib/rc-helpers), so the php it runs is the one they set the PATH for.

self="${BASH_SOURCE[0]}"
while [[ -L "$self" ]]; do
    link="$(readlink "$self")"
    [[ "$link" == /* ]] && self="$link" || self="$(dirname "$self")/$link"
done
dir="$(cd "$(dirname "$self")" && pwd -P)"

# shellcheck source=../lib/rc-helpers
source "$dir/../lib/rc-helpers"
read_rc "$dir/.."

exec php "$dir/opensim-api.php" "$@"
