Output and errors
Read kapten results as tables or JSON, filter them for scripts, and handle errors and exit codes.
Tables and JSON
Commands that list resources print a table of their main fields. Other commands print the resource as JSON. -o chooses the format:
kapten projects list # a table
kapten projects list -o json # the API's response, pagination included
kapten projects get <project-id> -o yaml
--rsh-columns chooses a table’s columns, and --rsh-sort-by the column its rows are sorted by:
kapten environments list <project-id> --rsh-columns name,type,id --rsh-sort-by name
Filter results
-f keeps only part of the response, with a jq expression. The response is under .body:
kapten projects list -f '.body.records[].id'
kapten projects get <project-id> -f '.body.name'
Lists return one page of results at a time: --page-limit sets the page size and --page-number the page.
Errors
When the API refuses a request, the CLI prints the error on one line to stderr and exits with status 1. stdout only ever holds results, so a script can pipe it safely. With -o json, the API’s error document is printed to stdout too.
When your session has ended, the error says to run kapten login again.
-v prints the HTTP requests and responses, without tokens, to help find what went wrong:
kapten projects list -v