txtpbfmt
parses, edits and formats text proto files in a way that preserves comments.
This saves development (read/edit/review) time and enables automated edits.
Install:
$ go install github.com/protocolbuffers/txtpbfmt/cmd/txtpbfmt@latest
Format files in-place:
$ ${GOPATH}/bin/txtpbfmt [FILES]
Write formatted input to stdout:
$ ${GOPATH}/bin/txtpbfmt < [FILE]
Main features:
Configurable features:
- Fields on
parser.Config
- Corresponding
# txtpbfmt: feature
names onparser.addToConfig
- Examples on config.md
Yes, see ast.go.
You can disable formatting for a whole file by adding a comment with "# txtpbfmt: disable" to the top of the file (before the first non-empty non-comment line), eg:
# File overview ...
# txtpbfmt: disable
content: { ... }
The .textproto
extension is the most used extension inside Google (the second
most popular choice is .textpb
).
Currently there is no open source integration with any editor.