plugin: handle --version/--help in protoc-gen-buffa{,-packaging}#86
Merged
plugin: handle --version/--help in protoc-gen-buffa{,-packaging}#86
Conversation
Both plugin binaries now respond to --version/-V and --help/-h instead of blocking on stdin, and any other CLI argument prints a "this is a protoc plugin" hint to stderr and exits 2. protoc/buf invoke plugins with no argv, so the stdin protocol path is unchanged.
|
All contributors have signed the CLA ✍️ ✅ |
rpb-ant
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Both plugin binaries now respond to
--version/-Vand--help/-hinstead of blocking on stdin (the previous behavior when invoked from a TTY:read_to_endwaits for Ctrl-D, then dumps a near-empty binaryCodeGeneratorResponse). Any other CLI argument prints a "this is a protoc plugin" hint to stderr and exits 2.protoc and buf invoke plugins with no argv (parameters travel inside
CodeGeneratorRequest.parameteron stdin), so the stdin protocol path is unchanged.Also drops the redundant
--plugin=protoc-gen-buffafrom the canonical protoc usage example (protoc findsprotoc-gen-*on PATH automatically;--plugin=is only needed to point at a non-PATH binary).Testing
Integration tests in each crate's
tests/cli.rsinvoke the built binary viaCARGO_BIN_EXE_*and cover--version,-V,--help/-h, and the unrecognized-arg path (asserting exit code 2).Semver
Additive CLI behavior on the two binary crates; no library API change. Suitable for 0.4.1.