Skip to main content

CLI OUTPUT

The Swamp CLI supports two output modes: log-mode (the default) and JSON mode.

Log-mode (default)

Human-readable, coloured terminal output. This is the default when no output mode override is set.

JSON mode

Structured JSON output, one object per line. Enable it with either:

  • The --json flag on any command.
  • The SWAMP_CLI_OUTPUT_JSON environment variable, which sets JSON as the persistent default.

SWAMP_CLI_OUTPUT_JSON

Value Effect
Unset, empty, 0, or false Log-mode (no effect)
Any other non-empty value (e.g., 1) JSON output by default

The --json flag on an individual command also enables JSON output regardless of the environment variable.

export SWAMP_CLI_OUTPUT_JSON=1
swamp model list          # JSON output
swamp workflow run deploy  # JSON output

Stream contract

stdout carries the command's output: human-readable prose in log mode, structured JSON in --json mode, and for a few commands a bare value suitable for piping, capturing, or redirecting.

stderr carries interaction and diagnostics: the progress spinner, the remote-execution indicator line, and every interactive prompt. In --json mode, a run that passes the account check offline also writes one JSON line to stderr, an object with warning and authMode: "offline".

Value-on-stdout commands

These commands write a single bare value to stdout so callers can pipe, capture, or redirect it without parsing:

Command stdout value
swamp invite link The referral URL
swamp first-rule The referral URL (easter egg)
swamp vault read-secret The decrypted secret (byte-exact)

Points notes, confirmation prompts, and progress indicators go to stderr, so they stay out of the captured value.

Scripting patterns

# Copy referral link to clipboard
swamp invite link | pbcopy

# Write a secret into a key file
swamp vault read-secret prod tls-key > /etc/ssl/key.pem

# Capture a secret into a variable
TOKEN=$(swamp vault read-secret prod api-token)

Prompts and non-interactive use

Interactive prompts (confirmations, secret inputs) are written to stderr. Silencing stderr on an interactive command hides the question rather than skipping it. Use --yes / -y to skip a confirmation non-interactively.


--log is not an output mode

The --log flag controls model and workflow run-log visibility — whether execution logs appear in terminal output. It does not select the output format. --log and --json can be combined: --json sets the format, --log adds run-log entries to it.

See also