#!/bin/sh
set -eu

mode="${1:-ui}"

case "$mode" in
    ui)
        exec frankenphp run --config /etc/Caddyfile
        ;;
    *)
        echo "Unknown mode: $mode" >&2
        echo "Usage: entrypoint.sh [ui]" >&2
        echo "" >&2
        echo "To run an ad-hoc PHP command (e.g. 'php', 'composer', 'vendor/bin/phpunit')," >&2
        echo "bypass this dispatcher with '--entrypoint <bin>'. For example:" >&2
        echo "  docker compose run --rm --entrypoint php ui vendor/bin/phpunit" >&2
        exit 1
        ;;
esac
