Exit codes
Every command of nkb ends with one of six numbers, and a number means the same thing whichever command returns it.
What does each code mean?
| Code | Meaning |
|---|---|
0 | The command did what it promised. |
1 | A pack did not pass validation. The finding is about the pack, not about the tool. |
2 | The command was called wrongly: an unknown command, an unknown option, or an option without its value. |
3 | The pack, the value or the file that was named does not exist. |
4 | The value could not be typed into the field. nkb send refused or stopped, and its message says why. |
5 | A file could not be read or written, or standard output could not be written. |
A command uses only the codes that can happen to it, and nkb lint --help and nkb fmt --help list theirs. Asking for help is a success, so --help exits with 0.
Will the codes change?
Not in meaning. The set is complete from the first release on purpose: a code added later would turn somebody’s green pipeline red without any change on their side.
How do I use them in CI?
nkb lint packs/my-pack.toml
status=$?
if [ "$status" -eq 1 ]; then
echo "the pack has errors"
elif [ "$status" -ne 0 ]; then
echo "nkb could not check it"
fi