Command line interface
See below for a the command line interface.
Toml sort: a sorting utility for toml files.
usage: toml-sort [-h] [--version] [-o OUTPUT] [-i] [-I] [-a]
[--no-sort-tables] [--sort-table-keys] [--sort-inline-tables]
[--sort-inline-arrays] [--no-header] [--no-comments]
[--no-header-comments] [--no-footer-comments]
[--no-inline-comments] [--no-block-comments]
[--spaces-before-inline-comment {1,2,3,4}]
[--spaces-indent-inline-array {2,4,6,8}]
[--trailing-comma-inline-array] [--check]
[F [F ...]]
Positional Arguments
- F
filename(s) to be processed by toml-sort (default: -)
Named Arguments
- --version
display version information and exit
Default: False
- -o, --output
output filepath (default: ‘-‘)
- -i, --in-place
overwrite the original input file with changes
Default: False
- --check
silently check if an original file would be changed by the formatter
Default: False
sort
change sorting behavior
- -I, --ignore-case
ignore case when sorting
Default: False
- -a, --all
sort ALL keys. This implies sort table-keys, inline-tables and inline arrays. (default: only sort non-inline ‘tables and arrays of tables’)
Default: False
- --no-sort-tables
Disables the default behavior of sorting tables and arrays of tables by their header value. Setting this option will keep the order of tables in the toml file the same.
Default: False
- --sort-table-keys
Sort the keys in tables and arrays of tables (excluding inline tables and arrays).
Default: False
- --sort-inline-tables
Sort inline tables.
Default: False
- --sort-inline-arrays
Sort inline arrays.
Default: False
formatting
options to change output formatting
- --spaces-before-inline-comment
Possible choices: 1, 2, 3, 4
the number of spaces before an inline comment (default: 1)
Default: 1
- --spaces-indent-inline-array
Possible choices: 2, 4, 6, 8
the number of spaces to indent a multiline inline array (default: 2)
Default: 2
- --trailing-comma-inline-array
add trailing comma to the last item in a multiline inline array
Default: False
Examples:
Stdin -> Stdout: cat input.toml | toml-sort
Disk -> Disk: toml-sort -o output.toml input.toml
Linting: toml-sort –check input.toml input2.toml input3.toml
Inplace Disk: toml-sort –in-place input.toml input2.toml
Return codes:
0 : success.
1 : errors were found
Notes:
You cannot redirect from a file to itself in Bash. POSIX shells process redirections first, then execute commands. –in-place exists for this reason
comments
exclude comments from output
Deprecated. See –no-header-comments
Default: False
remove all comments. Implies no header, footer, inline, or block comments
Default: False
remove a document’s leading comments
Default: False
remove a document’s trailing comments
Default: False
remove a document’s inline comments
Default: False
remove a document’s block comments
Default: False