Crates.io | yangfmt |
lib.rs | yangfmt |
version | 0.1.2 |
source | src |
created_at | 2023-04-09 19:00:42.028346 |
updated_at | 2023-04-10 21:56:09.6199 |
description | YANG code formatter |
homepage | https://github.com/Hubro/yangfmt |
repository | |
max_upload_size | |
id | 834485 |
size | 132,026 |
YANG code formatter
Clone the repo, then:
$ cargo install --path .
Pre-compiled binaries will be provided when the project has stabilized.
Pipe YANG source code to STDIN:
$ cat my-model.yang | yangfmt
Or specify a YANG file as the first positional argument:
$ yangfmt my-model.yang
Add -i
to format the given YANG file in place:
$ yangfmt -i my-model.yang
Pretty well tested, should be safe to use!
But please keep your code in version control just in case.
TODO:
Better error messages, currently syntax errors are reported raw with a character index
Instead, error messages should show the file name, line number and column number, plus details about the error.
Automatically indent the contents of multi-line strings to align with the first line
Handle comments in between string concatenations. Currently this causes a parse error. For example:
pattern "abcdef" // Comments here
+ "ghijkl"; // currently causes a parse error
Fortunately I've never seen anybody do this, but it's legal YANG so it should be supported.