Clone this repo:
  1. f6a6b3f Update documentation of Format function to say 'text proto' instead of 'metadata'. by Kauê Soares da Silveira · 5 months ago master
  2. ebd45c7 Keep list inline if it was originally inline. by txtpbfmt team · 9 months ago
  3. 52180c9 Preserve list syntax (e.g. "list: [1, 2]"). by txtpbfmt team · 9 months ago
  4. 6ac2702 Internal change by Miguel Alcon · 10 months ago
  5. 82b90ae Internal change by Kauê Soares da Silveira · 10 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?


$ go get -u

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.