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

LANG=${1:?usage: loop-release.sh <lang>}
STATUS=${2:-done}
ROOT=$(cd "$(dirname "$0")/.." && pwd)
cd "$ROOT"
LOCK=".loop-locks/$LANG.claim"
LOG=".loop-logs/$LANG.ndjson"
ISO=$(date -Iseconds)
rm -f "$LOCK"
printf '{"ts":"%s","lang":"%s","status":"released","exit":"%s"}\n' "$ISO" "$LANG" "$STATUS" >> "$LOG"
echo "OK: $LANG released ($STATUS)"
