Reference
Exit Codes
Tell success, runtime errors and usage errors apart by exit code.
| Exit code | Meaning | Typical codes |
|---|---|---|
0 | Success, including -h / --help and -V / --version | — |
1 | Runtime or API error: authentication, credits, network, server, failed run, timeout | unauthorized, insufficient_balance, network_error, task_failed, timeout |
2 | Usage error: a mistyped command or flag, or invalid input | usage_error, unknown_command, missing_input, too_many_images, file_not_found |
With exit code 2, retrying the same command won't help — fix it first. With 1, let the code decide whether to top up, re-authenticate or retry later. Which code falls in which group: Error codes.
Stdout holds a JSON envelope whether the command succeeds or fails, so you can use it alongside the exit code:
tufty pet-dressup --product ./sweater.jpg --model ./corgi.jpg --save ./out > result.json
case $? in
0) echo "done" ;;
2) echo "fix the command: $(jq -r .message result.json)" ;;
*) echo "failed: $(jq -r .code result.json)" ;;
esac