Enabling JSON output
Pass--json to any command:
--json explicitly in non-interactive contexts.
Output contract
Every response is a JSON object with anok boolean at the top level.
Success:
data varies by command, but ok is always present, and on a failure error.code and error.message are always present and stable. Some errors also carry two optional fields: error.hint (a recovery suggestion, e.g. the exact command to run) and error.spec (structured context). Both are omitted when empty.
Error codes
This is the common subset. Individual commands surface their own codes — for example
AMBIGUOUS (drawer connect), IMPORT_ERROR (import), INSTALL_ERROR / PUBLISH_ERROR (registry), DNS_CONFLICT / ZONE_MISMATCH (webhook setup), and NOT_APPLICABLE (board --json).
Checking exit codes
Buttons exits with code0 on success and 1 on any error, regardless of --json. Use the exit code in shell scripts:
Writing JSON in Go
Inside the Buttons codebase, useconfig.WriteJSON() and config.WriteJSONError() — never fmt.Println with raw JSON strings. This ensures consistent formatting and respects the --json / non-TTY detection logic.
Related
- Arguments —
MISSING_ARGandVALIDATION_ERRORdetails - Quick start — see JSON output in a real example