nkb fmt
Doprowadza plik paczki do postaci kanonicznej i nigdy nie zmienia tego, co plik mówi.
nkb fmt <file.toml> [--dry-run]
Co zmienia?
Kolejność pól w każdej tabeli, na tę, którą określa format, i odstęp przed każdym znakiem równości, żeby się wyrównały. Nic więcej: komentarze, puste wiersze i kolejność wartości zostają dokładnie takie, jakie są, bo kolejność wartości to kolejność, w jakiej spotyka je tester.
Jeśli zmiana zmieniłaby wartość, fmt niczego nie zapisuje i kończy się kodem 4. Formatter, który potrafiłby zmienić dane, które formatuje, byłby jeszcze jednym miejscem, w którym wartość może się zepsuć.
Przykłady
$ 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.
Opcje
Kody wyjścia
| Kod | Znaczenie |
|---|---|
0 | plik ma właściwą postać albo został do niej doprowadzony |
1 | plik nie jest TOML-em, więc nie było czego porządkować |
2 | polecenie wywołano niepoprawnie |
3 | pod tą ścieżką nie ma pliku paczki do odczytania |
4 | formatowanie zmieniłoby wartość, więc nic nie zostało zapisane |
5 | nie dało się odczytać albo zapisać pliku albo zapisać standardowego wyjścia |
Pomoc, tak jak wypisuje ją program
Co wypisuje nkb fmt --help (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