nkb fmt

Put a pack file in canonical shape, and never change what it says.

nkb fmt <file.toml> [--dry-run]

What does it change?

The order of the fields in each table, to the order the format defines, and the space before each equals sign, so they line up. Nothing else: comments, blank lines and the order of the values stay exactly as they are, because the order of the values is the order a tester meets them.

If a change would alter a value, fmt writes nothing and exits with 4. A formatter that could change the data it formats would be one more place for a value to break.

Examples

$ nkb fmt my-pack.toml --dry-run
my-pack.toml is not in shape. Run without --dry-run to rewrite it.
$ nkb fmt my-pack.toml
Wrote my-pack.toml in canonical shape.
$ nkb fmt my-pack.toml
my-pack.toml is already in shape. Nothing was written.

Options

--dry-run

Say what would change and write nothing

-h, --help

Show this help and exit with 0

Exit codes

CodeMeaning
0the file is in shape, or was put in shape
1the file is not TOML, so there was nothing to put in order
2the command was called wrongly
3there is no pack file to read at that path
4formatting would have changed a value, so nothing was written
5the file could not be read or written, or standard output could not be written

The help, as the program prints it

What nkb fmt --help prints, from nkb 0.1.0.

nkb fmt - rewrite a pack file in canonical shape

Usage:
  nkb fmt <file.toml> [--dry-run]

Puts the fields of each table in the order the format defines and lines
up the equals signs. Comments, blank lines and the order of the values
themselves are left exactly as they are - the order of the values is the
order a tester meets them.

Options:
      --dry-run  Say what would change and write nothing
  -h, --help     Show this help and exit with 0

Exit codes:
  0  the file is in shape, or was put in shape
  1  the file is not TOML, so there was nothing to put in order
  2  the command was called wrongly
  3  there is no pack file to read at that path
  4  formatting would have changed a value, so nothing was written
  5  the file could not be read or written, or standard output
     could not be written