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

COMPOSE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
BASE="${COMPOSE_DIR}/docker-compose.yml"
NATS="${COMPOSE_DIR}/docker-compose.nats-fsn.yml"
TELEM="${COMPOSE_DIR}/docker-compose.telemetry.yml"

if command -v docker compose >/dev/null 2>&1; then
  CMD="docker compose"
else
  CMD="docker-compose"
fi

if [[ $# -eq 0 ]]; then
  echo "Usage: $0 up|down|ps|logs [weitere docker-compose Argumente]"
  echo "Beispiele:"
  echo "  $0 up -d           # kompletten COM-Stack starten"
  echo "  $0 down            # kompletten COM-Stack stoppen"
  echo "  $0 ps              # Status aller COM-Container"
  echo "  $0 logs hxki-n8n   # Logs eines Dienstes"
  exit 1
fi

"$CMD" -f "$BASE" -f "$NATS" -f "$TELEM" "$@"
