Skip to content

plugin: handle --version/--help in protoc-gen-buffa{,-packaging}#86

Merged
iainmcgin merged 1 commit intomainfrom
feat/plugin-version-help
Apr 30, 2026
Merged

plugin: handle --version/--help in protoc-gen-buffa{,-packaging}#86
iainmcgin merged 1 commit intomainfrom
feat/plugin-version-help

Conversation

@iainmcgin
Copy link
Copy Markdown
Collaborator

Both plugin binaries now respond to --version / -V and --help / -h instead of blocking on stdin (the previous behavior when invoked from a TTY: read_to_end waits for Ctrl-D, then dumps a near-empty binary CodeGeneratorResponse). 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.parameter on stdin), so the stdin protocol path is unchanged.

$ protoc-gen-buffa --version
protoc-gen-buffa 0.4.0
$ protoc-gen-buffa-packaging -V
protoc-gen-buffa-packaging 0.4.0

Also drops the redundant --plugin=protoc-gen-buffa from the canonical protoc usage example (protoc finds protoc-gen-* on PATH automatically; --plugin= is only needed to point at a non-PATH binary).

Testing

Integration tests in each crate's tests/cli.rs invoke the built binary via CARGO_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.

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.
@github-actions
Copy link
Copy Markdown

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@iainmcgin iainmcgin marked this pull request as ready for review April 29, 2026 22:47
@iainmcgin iainmcgin requested a review from rpb-ant April 29, 2026 22:49
@iainmcgin iainmcgin enabled auto-merge (squash) April 29, 2026 22:49
@iainmcgin iainmcgin merged commit df1e253 into main Apr 30, 2026
7 checks passed
@iainmcgin iainmcgin deleted the feat/plugin-version-help branch April 30, 2026 00:47
@github-actions github-actions Bot locked and limited conversation to collaborators Apr 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants