Clone this repo:
  1. 69891ed Default Config path to CWD if not specified; Update README.md (#26) by Christopher Anderson · 3 months ago main upstream/main v0.5.0
  2. 6af969c Add 'indent_str' option to Config to change the indent type (#24) by Christopher Anderson · 3 months ago
  3. 4f15b0d Support/fix unit-address (#25) by Christopher Anderson · 3 months ago
  4. 8bf55e1 Generalize parsing and add handling for byte_string_literal and file_header (#23) by Christopher Anderson · 3 months ago
  5. d4a0c38 Use nightly toolchain in workflows so format action works (#22) by Christopher Anderson · 3 months ago

dtsfmt

Auto formatter for device tree files.

Installation

You can install dtsfmt by running the install script which will download the latest release.

curl -LSfs https://go.mskelton.dev/dtsfmt/install | sh

Or you can build from source.

git clone --recurse-submodules https://github.com/mskelton/dtsfmt.git
cd dtsfmt
cargo install --path .

Usage

To run dtsfmt, simply provide a file/directory path to the dtsfmt command.

dtsfmt .

Config

The following configuration options are available for dtsfmt. Configuration should be added to a .dtsfmtrc.toml file at the root of your project.

indent_str = "  " # Optional, used for each indent level when printing.
# Default is two spaces.
layout = "kinesis:adv360" # Required
# Available options are ["kinesis:adv360", "sweep", "moergo:glove80"]
warn_on_unhandled_tokens = false # Optional
# Used to check if an input file contains any tokens not handled by the parser/printer.

Ignoring code

You can add a .dtsfmtignore file at the root of your project to exclude files and paths from formatting. This file follows the same rules as .gitignore.

Flags

--check

When you want to check if your files are formatted, you can run dtsfmt with the --check flag (or -c). This will output a human-friendly message and a list of unformatted files, if any.

dtsfmt --check .

--stdin

If passed the --stdin flag dtsfmt will read from stdin and write to stdout.

dtsfmt --stdin < input.dts > output.dts