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?

CodeMeaning
0The command did what it promised.
1A pack did not pass validation. The finding is about the pack, not about the tool.
2The command was called wrongly: an unknown command, an unknown option, or an option without its value.
3The pack, the value or the file that was named does not exist.
4The value could not be typed into the field. nkb send refused or stopped, and its message says why.
5A 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