prototext - Lossless protobuf ↔ enhanced-textproto
converter
prototext [-d|--decode]
[-e|--encode] [-D|--descriptor]
[-t|--type] [--annotations] [--no-annotations]
[-o|--output] [-O|--output-root]
[-I|--input-root] [-i|--in-place]
[-q|--quiet] [-h|--help]
[-V|--version] [PATH]
Lossless protobuf ↔ enhanced-textproto converter
- -d, --decode
- Decode: treat input as binary protobuf, emit text
- -e, --encode
- Encode: treat input as textual prototext, emit binary
- -D, --descriptor
<PATH>
- Compiled .pb descriptor file
- -t, --type
<NAME>
- Fully-qualified root message type name (e.g. pkg.MyMessage). When given
without --descriptor, uses the embedded descriptor (covers all
google.protobuf.* types)
- --annotations
- Emit inline wire-type/field-number comments (default). Required for
lossless round-trip encode
- --no-annotations
- Suppress inline wire-type/field-number comments. Output will not be
losslessly round-trippable
- -o, --output
<PATH>
- Write output to PATH (single input only; exclusive with
--output-root)
- -O, --output-root
<DIR>
- Root directory for output files in batch mode (exclusive with --output and
--in-place)
- -I, --input-root
<DIR>
- Root directory: positional paths and globs are resolved relative to DIR.
Absolute positional paths are an error when --input-root is given
- -i,
--in-place
- Rewrite each input file in place (exclusive with --output-root). Each file
is read fully into memory before being overwritten (sponge)
- -q, --quiet
- Suppress warnings on stderr (errors are always printed)
- -h, --help
- Print help
- -V, --version
- Print version
- [PATH]
- Input files, glob patterns, or directories (recursive). When absent, reads
from stdin
- PROTOTEXT_COMPLETE
- When set to bash, zsh, or fish, print a shell
completion script to stdout and exit. Used by the shell completion setup
described below.
prototext -d message.binpb
prototext -d -D descriptor.pb -t pkg.MyMessage message.binpb
prototext -e message.pb > message.binpb
protoc --encode=pkg.MyMessage descriptor.proto < input.txt | prototext -d -D descriptor.pb -t pkg.MyMessage
source <(PROTOTEXT_COMPLETE=bash prototext)