`txtpbfmt`: Add support for formatting repeated primitive fields as lists. When this option is used, repeated primitive fields are printed using a more conscice list syntax: ```textproto repeated_field: 1 repeated_field: 2 repeated_field: 3 ``` vs ```textproto repeated_field: [1, 2, 3] ``` This syntax is part of the go/textformat-spec (screen/4cDavcUGvdjyWwN), thus it's supported by all parsers. Furthermore, some proto implementations (like [C++](http://google3/third_party/protobuf/text_format.h;l=407;rcl=828248838) and [Java](http://google3/third_party/java_src/protobuf/current/java/com/google/protobuf/TextFormat.java;l=385;rcl=815831657)) allow using it when printing text-proto. This CL is a no-op if the config option isn't used. PiperOrigin-RevId: 836120469
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:
parser.Config# txtpbfmt: feature names on parser.addToConfigYes, 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.