Skip to content

Output and exit codes

dinio is made to be scripted. Two things are a stable contract: the -o json output and the exit codes.

By default results are printed as tables for people. -o json prints the same result as JSON, in the API’s field names:

Terminal window
dinio zone list -o json | jq -r '.[].name'
dinio record show example.com www A -o json | jq -r '.values[].uuid'

Results go to stdout; messages for people (zone example.com created) and errors go to stderr. So dinio … | grep and dinio … > file only see results.

Secrets are never printed: API keys are shown masked (…a1b2), and certificate keys not at all. The only exceptions are zone key create and me key create, which print the new key once.

Code Meaning
0 Success.
1 Unexpected error, bad config, or a declined confirmation.
2 Wrong arguments.
3 Authentication or authorization: no key, rejected key, 403 — including a suspended zone or client, and a package limit.
4 Not found: 404, or no record value with that data.
5 Conflict: 409, e.g. a record that breaks a zone rule, or a record or certificate Dinio keeps for a redirect.
6 Validation: 400 / 422, input the CLI rejected before sending, a zone import that refused records, or a failed discovery.
7 Network: DNS, TLS, connection, timeout.
8 Server error (5xx) or an unexpected response.
Terminal window
dinio record show example.com www A >/dev/null 2>&1
case $? in
0) echo "exists" ;;
4) echo "missing" ;;
*) echo "could not check" >&2; exit 1 ;;
esac

Commands that delete something, replace a key or write in bulk ask before they act: zone delete, zone key create, zone key revoke, zone import, me key create, me key revoke, record rm, health rm, geo-ban rm --all, member rm, redirect rm, cert rm, client new-identify, client delete, sinkhole delete, sinkhole import when it would remove rules, sinkhole source set, sinkhole rule rm and sinkhole link rm — and every command that would overwrite an existing file. Pass -y / --yes to skip the question. Without a terminal (in CI, in a pipe) and without --yes, they refuse and exit with 1 — they never assume “yes”.

Terminal window
dinio completion bash > ~/.local/share/bash-completion/completions/dinio
dinio completion zsh > "${fpath[1]}/_dinio"
dinio completion fish > ~/.config/fish/completions/dinio.fish
dinio completion powershell >> $PROFILE