Clone this repo:
  1. f293424 Move quote functions to a separate package. by Kauê Soares da Silveira · 4 days ago master
  2. 5749ee8 Factor wrapping code into separate package. by Kauê Soares da Silveira · 4 days ago
  3. 882eecd Extract printing into its own file. by Kauê Soares da Silveira · 4 days ago
  4. df82afe Move implementation from parser.go to impl.go. by Kauê Soares da Silveira · 4 days ago
  5. b5dd51e Make private the symbols that don't have any users. by Kauê Soares da Silveira · 4 days 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

Configurable 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