Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/hougesen/kdlfmt
A formatter for kdl documents.
https://github.com/hougesen/kdlfmt
code-formatter formatter kdl rust
Last synced: 2 months ago
JSON representation
A formatter for kdl documents.
- Host: GitHub
- URL: https://github.com/hougesen/kdlfmt
- Owner: hougesen
- License: mit
- Created: 2024-06-06T18:18:35.000Z (7 months ago)
- Default Branch: main
- Last Pushed: 2024-10-01T00:57:33.000Z (3 months ago)
- Last Synced: 2024-10-12T18:27:35.562Z (3 months ago)
- Topics: code-formatter, formatter, kdl, rust
- Language: Rust
- Homepage:
- Size: 110 KB
- Stars: 4
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# kdlfmt
A formatter for [kdl](https://kdl.dev) documents.
kdlfmt is a thin cli wrapper built on-top of the official `kdl` parser for Rust ([`kdl-rs`](https://github.com/kdl-org/kdl-rs)), so any formatting/parsing issues should be reported there.
```
A code formatter for kdl documents.Usage: kdlfmt
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](https://crates.io/crates/kdlfmt)).
```shell
cargo install kdlfmt
```If you do not have/want Rust installed on your device you can find precompiled binaries on the [release](https://github.com/hougesen/kdlfmt/releases) page.
## Usage
Once installed the formatted can be invoked by running `kdlfmt format`.
```shell
kdlfmt format PATH
``````
Format kdl filesUsage: kdlfmt format [OPTIONS]
Arguments:
Path to file OR directory. Use "-" to read from stdinOptions:
--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.
```shell
kdlfmt check PATH
``````
Validate files are formattedUsage: kdlfmt check [OPTIONS]
Arguments:
Path to file OR directory. Use "-" to read from stdinOptions:
--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 completionsUsage: kdlfmt completions
Arguments:
[possible values: bash, elvish, fish, powershell, zsh]Options:
-h, --help Print help
-V, --version Print version```
#### Bash
Add the following to your `.bashrc`.
```bash
eval "$(kdlfmt completions bash)"
```#### Bash
Add the following to your `.zshrc`:
```zsh
eval "$(kdlfmt completions zsh)"
```#### Fish
Add the following to `~/.config/fish/config.fish`.
```fish
kdlfmt completions fish | source
```#### PowerShell
Add the following to your PowerShell configuration (Can be found by running `$PROFILE`).
```powershell
Invoke-Expression (&kdlfmt completions powershell)
```#### Elvish
Add the following to `~/.elvish/rc.elv`.
```elvish
eval (kdlfmt completions elvish)
```