Scripting And JSON Output
Structured output
Section titled “Structured output”Use JSON output whenever another tool needs to parse the result:
gaard whoami -o jsongaard token list -o jsongaard tenant list -o jsonTable output is the default for interactive terminal use.
Context and tenant overrides
Section titled “Context and tenant overrides”You do not need to switch the global config just to run one command against a different environment.
Run a command against a specific context:
gaard --context staging whoami -o jsonRun a command against a specific tenant:
gaard --context prod --tenant acme_prod token list -o jsonNon-interactive patterns
Section titled “Non-interactive patterns”Good automation patterns:
- Prefer
-o json - Pass
--contextand--tenantexplicitly when the environment matters - Use
--no-colorwhen logs may be parsed or stored - Store custom config files with
GAARD_CONFIGwhen running isolated jobs
Example:
GAARD_CONFIG=/tmp/gaard-ci.yaml \ gaard --context staging --tenant acme_prod whoami -o json --no-colorToken management for automation
Section titled “Token management for automation”Use gaard token create to mint a personal access token for a bot or script:
gaard token create --name ci-bot --expires 720hThe command prints the raw token once. Store it immediately in your secret manager or CI variable store.
Human-friendly versus machine-friendly output
Section titled “Human-friendly versus machine-friendly output”Choose output based on the caller:
tablefor humans in a terminaljsonfor scripts, CI, and AI agents
If you are building higher-level automation, prefer wrapping gaard commands rather than scraping table output.