#!/bin/sh
set -eu

DIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)
. "$DIR/lib/common.sh"

usage() {
  echo "Usage: DockerStatsSnapshot [--container NAME_OR_ID]" >&2
}

_ac_handle_help usage "$@"
_ac_require docker

container=""

_ac_parse_args \
  container:str \
  -- "$@"

# Output: NDJSON (one JSON object per line)
if [ -n "$container" ]; then
  exec docker stats --no-stream --format '{{json .}}' "$container"
fi
exec docker stats --no-stream --format '{{json .}}'
