#!/usr/bin/env bash
# enroll.sh [--dry-run] — enrol {{name}} on tiny.technology as an ENDPOINT body. One line: everything else is
# in tiny.body.json (this repo) and tiny-tech itself.
#   url     {{SLUG}}_PUBLIC_URL (https + public hostname, e.g. a Cloudflare tunnel) — or pass --endpoint https://…
#   bearer  {{SLUG}}_TOKEN, else ~/.{{slug}}/token (what server.py accepts) — never on argv, never printed
#   door    owner session on this box → POST /api/devices; none → 6-char pairing code + QR to approve in the tiny app
#   rerun   safe: the same-name endpoint row is re-pointed, never duplicated
cd "$(dirname "$0")" && exec npx -y tiny-tech@latest enroll --body {{slug}} "$@"
