### Install kdlfmt using npm Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Installs the kdlfmt package globally using npm and provides an example of how to format files. ```shell npm install -g kdlfmt kdlfmt format . ``` -------------------------------- ### Configuration File Example Source: https://context7.com/hougesen/kdlfmt/llms.txt Example content for the kdlfmt.kdl configuration file. ```kdl // Amount of spaces to use for each indentation level indent_size 4 // Whether to use tabs or spaces for indentation use_tabs false ``` -------------------------------- ### Install kdlfmt using Linux/MacOS Installer Script Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Downloads and executes an installer script to install kdlfmt on Linux and macOS systems without requiring Rust or Homebrew. ```shell curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hougesen/kdlfmt/releases/latest/download/kdlfmt-installer.sh | sh ``` -------------------------------- ### Install kdlfmt via package managers Source: https://context7.com/hougesen/kdlfmt/llms.txt Supported installation methods include Cargo, Homebrew, npm, and shell/PowerShell installers. ```bash # Using Cargo (Rust package manager) cargo install kdlfmt # Using Homebrew (macOS/Linux) brew install hougesen/tap/kdlfmt # Using npm npm install -g kdlfmt npx kdlfmt format . # Shell installer (Linux/macOS) curl --proto '=https' --tlsv1.2 -LsSf https://github.com/hougesen/kdlfmt/releases/latest/download/kdlfmt-installer.sh | sh # PowerShell installer (Windows) powershell -ExecutionPolicy ByPass -c "irm https://github.com/hougesen/kdlfmt/releases/latest/download/kdlfmt-installer.ps1 | iex" ``` -------------------------------- ### GitHub Actions Workflow for kdlfmt Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Example GitHub Actions workflow to automatically format KDL files on push. This workflow checks out the repository, installs kdlfmt, runs the formatter, and commits changes. ```yaml name: kdlfmt on: - push jobs: format: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install kdlfmt uses: hougesen/kdlfmt@main - name: Run kdlfmt format run: kdlfmt format . - name: Commit changes uses: EndBug/add-and-commit@v9 with: message: "style: formatted kdl" ``` -------------------------------- ### Install kdlfmt using Homebrew Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Installs kdlfmt on macOS or Linux using Homebrew by first tapping the repository and then installing the package. ```shell # Tap and install brew tap hougesen/tap brew install kdlfmt # Or install directly in one command brew install hougesen/tap/kdlfmt ``` -------------------------------- ### kdlfmt Configuration Example Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Sample configuration for kdlfmt. Use `kdlfmt init` to create a configuration file. Adjust `indent_size` and `use_tabs` as needed. ```kdl // Amount of spaces to use for each indentation level indent_size 4 // Whether to use tabs or spaces for indentation use_tabs #false ``` -------------------------------- ### Install kdlfmt using Cargo Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Installs the kdlfmt CLI tool using Cargo, the package manager for Rust. ```shell cargo install kdlfmt ``` -------------------------------- ### Install kdlfmt using Windows PowerShell Installer Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Downloads and executes a PowerShell script to install kdlfmt on Windows systems, bypassing execution policy restrictions. ```powershell powershell -ExecutionPolicy ByPass -c "irm https://github.com/hougesen/kdlfmt/releases/latest/download/kdlfmt-installer.ps1 | iex" ``` -------------------------------- ### GitHub Action Integration Source: https://context7.com/hougesen/kdlfmt/llms.txt Example workflow configuration for using kdlfmt in GitHub Actions. ```yaml name: kdlfmt on: - push - pull_request jobs: format: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install kdlfmt uses: hougesen/kdlfmt@main # Optionally specify version: # with: # version: "0.1.6" - name: Run kdlfmt check run: kdlfmt check . auto-format: runs-on: ubuntu-latest steps: - name: Checkout repository uses: actions/checkout@v4 - name: Install kdlfmt uses: hougesen/kdlfmt@main - name: Run kdlfmt format run: kdlfmt format . - name: Commit changes uses: EndBug/add-and-commit@v9 with: message: "style: formatted kdl" ``` -------------------------------- ### Run kdlfmt using npx Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Executes the kdlfmt command directly using npx without a global installation. ```shell npx kdlfmt format . ``` -------------------------------- ### pre-commit Configuration for kdlfmt Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Configuration for using kdlfmt with pre-commit. Ensure you have pre-commit installed and add this to your `.pre-commit-config.yaml` file. ```yaml repos: - repo: https://github.com/hougesen/kdlfmt rev: main hooks: - id: kdlfmt-format ``` -------------------------------- ### Initialize Configuration Source: https://context7.com/hougesen/kdlfmt/llms.txt Creates or manages the kdlfmt.kdl configuration file for formatting preferences. ```bash # Create default configuration file kdlfmt init # Force overwrite existing config kdlfmt init --force # Initialize with specific KDL version kdlfmt init --kdl-version v2 ``` -------------------------------- ### kdlfmt Base Command Help Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Displays the main usage and available commands for the kdlfmt CLI tool, including format, check, init, completions, and help. ```shell kdlfmt 0.1.6 A code formatter for kdl documents. Mads Hougesen Usage: kdlfmt [OPTIONS] Commands: format Format kdl files check Validate files are formatted init Initialize formatter config completions Generate shell completions help Print this message or the help of the given subcommand(s) Options: --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help -V, --version Print version ``` -------------------------------- ### kdlfmt Format Command Help Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Displays detailed usage information for the 'kdlfmt format' command, including options for input paths, KDL version, stdin, configuration, and logging. ```shell Format kdl files Usage: kdlfmt format [OPTIONS] [INPUT]... Arguments: [INPUT]... Path to file OR directory. Use "-" to read from stdin and print to stdout. Options: --kdl-version kdl specification to use. By default all versions are tried [possible values: v1, v2] --stdin Read from stdin and print to stdout --config Path to config file --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` -------------------------------- ### kdlfmt Check Command Help Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Displays detailed usage information for the 'kdlfmt check' command, including options for input paths, KDL version, stdin, configuration, and logging. ```shell Validate files are formatted Usage: kdlfmt check [OPTIONS] [INPUT]... Arguments: [INPUT]... Path to file OR directory. Use "-" to read from stdin and print to stdout. Options: --kdl-version kdl specification to use. By default all versions are tried [possible values: v1, v2] --stdin Read from stdin and print to stdout --config Path to config file --log-level [possible values: trace, debug, info, warn, error, off] -h, --help Print help (see a summary with '-h') -V, --version Print version ``` -------------------------------- ### kdlfmt Shell Completion - Fish Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Add this command to `~/.config/fish/config.fish` to enable fish shell completion for kdlfmt. ```fish kdlfmt completions fish | source ``` -------------------------------- ### Check KDL files by path Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Validates if KDL files specified by path are correctly formatted. Use '-' to read from stdin. ```shell kdlfmt check PATH ``` -------------------------------- ### Format KDL files by path Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Formats KDL files specified by path. Use '-' to read from stdin and print to stdout. ```shell kdlfmt format PATH ``` -------------------------------- ### Configure ignored files with .kdlfmtignore Source: https://context7.com/hougesen/kdlfmt/llms.txt Use gitignore-style syntax to exclude specific files or directories from formatting operations. ```gitignore # .kdlfmtignore # Ignore generated files generated/ dist/ # Ignore specific files legacy-config.kdl # Ignore test fixtures **/fixtures/*.kdl ``` -------------------------------- ### kdlfmt Shell Completion - Elvish Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Add this command to `~/.elvish/rc.elv` to enable Elvish shell completion for kdlfmt. ```elvish eval (kdlfmt completions elvish) ``` -------------------------------- ### Pre-commit Hook Integration Source: https://context7.com/hougesen/kdlfmt/llms.txt Configuration for integrating kdlfmt into pre-commit workflows. ```yaml # .pre-commit-config.yaml repos: - repo: https://github.com/hougesen/kdlfmt rev: main hooks: # Format files automatically - id: kdlfmt-format # Or check files without modifying (fails if unformatted) - id: kdlfmt-check ``` -------------------------------- ### treefmt Configuration for kdlfmt Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Configuration to integrate kdlfmt with treefmt. Add this to your `treefmt.toml` file to enable automatic formatting of KDL files. ```toml # treefmt.toml [formatter.kdlfmt] command = "kdlfmt" options = ["format"] includes = ["*.kdl"] ``` -------------------------------- ### Specify KDL version for formatting Source: https://context7.com/hougesen/kdlfmt/llms.txt Explicitly define the KDL specification version to ensure consistent parsing behavior. ```bash # Format using KDL v2 specification kdlfmt format --kdl-version v2 modern-config.kdl # Format using KDL v1 specification for legacy compatibility kdlfmt format --kdl-version v1 legacy-config.kdl # Check with explicit version kdlfmt check --kdl-version v2 . # Auto-detect version (default behavior - tries v2 first, then v1) kdlfmt format config.kdl ``` -------------------------------- ### Format KDL Files Source: https://context7.com/hougesen/kdlfmt/llms.txt Formats KDL files in place using various input methods including files, directories, and stdin. ```bash # Format a single file kdlfmt format config.kdl # Format all KDL files in a directory recursively kdlfmt format . # Format multiple paths kdlfmt format ./configs ./templates/app.kdl # Format with specific KDL version kdlfmt format --kdl-version v2 config.kdl # Format from stdin and output to stdout cat config.kdl | kdlfmt format - # Using --stdin flag explicitly echo 'node "value"' | kdlfmt format --stdin # Use custom config file kdlfmt format --config /path/to/kdlfmt.kdl . ``` -------------------------------- ### kdlfmt Shell Completion - Nushell Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Generate shell completions for Nushell using this command. ```nushell kdlfmt completions nushell ``` -------------------------------- ### Check KDL File Formatting Source: https://context7.com/hougesen/kdlfmt/llms.txt Validates file formatting without modification, returning a non-zero exit code if formatting is required. ```bash # Check a single file kdlfmt check config.kdl # Check all KDL files in current directory kdlfmt check . # Check with specific KDL version kdlfmt check --kdl-version v1 legacy-config.kdl # Check from stdin cat config.kdl | kdlfmt check - # Use in CI - exits with error if files need formatting kdlfmt check . || echo "Some files need formatting" ``` -------------------------------- ### Format KDL from stdin Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Reads KDL content from stdin and prints the formatted output to stdout. ```shell cat somefile.kdl | kdlfmt format - ``` -------------------------------- ### Generate Shell Completions Source: https://context7.com/hougesen/kdlfmt/llms.txt Generates shell completion scripts for various environments to enable tab completion. ```bash # Generate bash completions (add to .bashrc) eval "$(kdlfmt completions bash)" # Generate zsh completions (add to .zshrc) eval "$(kdlfmt completions zsh)" # Generate fish completions (add to config.fish) kdlfmt completions fish | source # Generate PowerShell completions Invoke-Expression (&kdlfmt completions powershell) # Generate elvish completions (add to rc.elv) eval (kdlfmt completions elvish) # Generate nushell completions kdlfmt completions nushell ``` -------------------------------- ### treefmt Integration Source: https://context7.com/hougesen/kdlfmt/llms.txt Configuration for using kdlfmt within a treefmt project. ```toml # treefmt.toml [formatter.kdlfmt] command = "kdlfmt" options = ["format"] includes = ["*.kdl"] ``` -------------------------------- ### kdlfmt Shell Completion - PowerShell Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Add this command to your PowerShell configuration (found by running `$PROFILE`) to enable PowerShell shell completion for kdlfmt. ```powershell Invoke-Expression (&kdlfmt completions powershell) ``` -------------------------------- ### kdlfmt Shell Completion - Zsh Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Add this command to your `.zshrc` to enable zsh shell completion for kdlfmt. ```zsh eval "$(kdlfmt completions zsh)" ``` -------------------------------- ### Check KDL from stdin Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Reads KDL content from stdin and checks if it is correctly formatted, printing the result to stdout. ```shell cat somefile.kdl | kdlfmt check - ``` -------------------------------- ### kdlfmt Shell Completion - Bash Source: https://github.com/hougesen/kdlfmt/blob/main/README.md Add this command to your `.bashrc` to enable bash shell completion for kdlfmt. ```bash eval "$(kdlfmt completions bash)" ``` -------------------------------- ### Configure log verbosity Source: https://context7.com/hougesen/kdlfmt/llms.txt Adjust output verbosity using the --log-level flag for debugging or script integration. ```bash # Verbose debug output kdlfmt --log-level debug format . # Show only errors kdlfmt --log-level error check . # Completely silent operation kdlfmt --log-level off format . # Available levels: trace, debug, info, warn, error, off ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.