13 releases

0.1.11 Jan 15, 2024
0.1.10 Jan 2, 2024
0.1.9 Dec 31, 2023

#840 in Parser implementations

Download history 9/week @ 2023-12-27 11/week @ 2024-01-10 6/week @ 2024-02-14 19/week @ 2024-02-21 1/week @ 2024-02-28 1/week @ 2024-03-06

166 downloads per month

MIT license

99KB
2.5K SLoC

cmakefmt

Crates.io Version


Good enough CMake auto formatter. No settings, prints to STDOUT.

Install

cargo install cmakefmt

Usage

cmakefmt <file>

State

  • Basic syntax is handled and prints
  • Error handling prints nice error messages, but it's very verbose and sometimes the true parsing error is deeper into the file
  • Ignores commas after quoted string literals since that just breaks string commands and isn't valid syntax
  • Fails to parse conditional expressions if comments are put before a binary conditional operator (AND/OR etc.)

Rules

  • Statements and commands are printed in one line or break into multiple lines if there isn't space
  • Command arguments are broken into one line each, unless they are an upper-case word. In case an argument is an upper-case word, it creates a group with all the following non-uppercase arguments. This helps format key-value style bringings.
  • Group-like statements (foreach, if, block, macro) indent their children

License

MIT

Dependencies

~4–12MB
~120K SLoC