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

# @describe Stop a sandbox container (it will be removed if started with --rm).
# @option --container! Container name/id to stop.

main() {
  local c="${argc_container}"
  if docker ps --format '{{.Names}}' | grep -qx "$c"; then
    docker stop "$c" >/dev/null
    printf '{"container":"%s","status":"stopped"}\n' "$c" >> "$LLM_OUTPUT"
  else
    printf '{"container":"%s","status":"not-running"}\n' "$c" >> "$LLM_OUTPUT"
  fi
}

eval "$(argc --argc-eval "$0" "$@")"

