6 releases

new 0.0.5 Oct 23, 2024
0.0.4 Oct 23, 2024
0.0.3 Aug 6, 2024
0.0.2 Jul 10, 2024
0.0.1 Jun 6, 2024

#489 in Development tools

Download history 94/week @ 2024-07-06 15/week @ 2024-07-13 12/week @ 2024-07-20 41/week @ 2024-07-27 132/week @ 2024-08-03 15/week @ 2024-08-10 1/week @ 2024-08-17 18/week @ 2024-08-24 21/week @ 2024-08-31 2/week @ 2024-09-07 15/week @ 2024-09-14 34/week @ 2024-09-21 54/week @ 2024-09-28 29/week @ 2024-10-05 6/week @ 2024-10-12 271/week @ 2024-10-19

367 downloads per month

MIT license

19KB
432 lines

kdlfmt

A formatter for kdl documents.

kdlfmt is a thin cli wrapper built on-top of the official kdl parser for Rust (kdl-rs), so any formatting/parsing issues should be reported there.

A code formatter for kdl documents.

Usage: kdlfmt <COMMAND>

Commands:
  format       Format kdl files
  check        Validate files are formatted
  completions  Generate shell completions
  help         Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

Installation

kdlfmt can be installed using Cargo, the package manager for Rust (crates.io).

cargo install kdlfmt

If you do not have/want Rust installed on your device you can find precompiled binaries on the release page.

Usage

Once installed the formatted can be invoked by running kdlfmt format.

kdlfmt format PATH
Format kdl files

Usage: kdlfmt format [OPTIONS] <INPUT>

Arguments:
  <INPUT>  Path to file OR directory. Use "-" to read from stdin

Options:
      --log-level <LOG_LEVEL>  [possible values: trace, debug, info, warn, error, off]
  -h, --help                   Print help
  -V, --version                Print version

Validating files are formatted

kdlfmt also support validating if files are formatted using the kdlfmt check command.

kdlfmt check PATH
Validate files are formatted

Usage: kdlfmt check [OPTIONS] <INPUT>

Arguments:
  <INPUT>  Path to file OR directory. Use "-" to read from stdin

Options:
      --log-level <LOG_LEVEL>  [possible values: trace, debug, info, warn, error, off]
  -h, --help                   Print help
  -V, --version                Print version

Ignoring files

.kdlfmtignore files are used to ignore files/directories.

It uses the same syntax as .gitignore files.

Shell completion

Shell completion can be generated using the kdl completions command.

Generate shell completions

Usage: kdlfmt completions <SHELL>

Arguments:
  <SHELL>  [possible values: bash, elvish, fish, powershell, zsh]

Options:
  -h, --help     Print help
  -V, --version  Print version

Bash

Add the following to your .bashrc.

eval "$(kdlfmt completions bash)"

Bash

Add the following to your .zshrc:

eval "$(kdlfmt completions zsh)"

Fish

Add the following to ~/.config/fish/config.fish.

kdlfmt completions fish | source

PowerShell

Add the following to your PowerShell configuration (Can be found by running $PROFILE).

Invoke-Expression (&kdlfmt completions powershell)

Elvish

Add the following to ~/.elvish/rc.elv.

eval (kdlfmt completions elvish)

Dependencies

~8–17MB
~229K SLoC