Clone this repo:
  1. fa9f017 trim trailing newlines by Kauê Soares da Silveira · 7 weeks ago master
  2. 7962e19 trim trailing newlines by Mike Frysinger · 7 weeks ago
  3. 3462fbc Add more flags to fmt command. by txtpbfmt team · 9 weeks ago
  4. 7e3b713 Auto-disable WrapStringsAfterNewlines for binary-ish strings. by txtpbfmt team · 9 weeks ago
  5. 0e3c6a0 Allow <stdin> to be called something else in log/error messages by txtpbfmt team · 3 months ago

Text Proto Formatter

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.

How to format existing text proto files?

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]

What does it do?

Main features:

main features

Is there an API to edit text proto files while preserving comments?

Yes, see ast.go.

How to disable it?

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: { ... }

Which file extension should I use for my text proto files?

The .textproto extension is the most used extension inside Google (the second most popular choice is .textpb).

Which tools support it? How to format on save?

Currently there is no open source integration with any editor.

See also