Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

teach protoc-gen-ruby PB_{DUMP,LOAD}_REQUEST_BYTES #307

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

embark
Copy link
Contributor

@embark embark commented Feb 23, 2016

PB_DUMP_REQUEST_BYTES=foo.bin protoc foo.proto --plugin=protoc-gen-gem=bin/protoc-gen-ruby --gem_out=.
will dump the raw proto request bytes generated by protoc for foo.proto to foo.bin
FUTURE USE CASE: functional tests to come that rely on checked-in bin files

PB_LOAD_REQUEST_BYTES=foo.bin bin/protoc-gen-ruby
will read the raw request bytes from foo.bin and print the generated
code (actually it is the code gen response proto, but it is still
readable) to STDOUT
CURRENT USE CASE: makes it so you can use pry when testing code generation. If you gave the code generator input from stdin, then pry would get the command to close at the end of the stdin input.

unless File.directory?(File.dirname(dump_file))
warn "PB_DUMP_REQUEST_BYTES=#{dump_file.inspect} is not a valid path for the request bytes"
warn "Usage: PB_DUMP_REQUEST_BYTES=/path/to/desired/dump/file.bin protoc blah.proto"
exit 1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nerdrew did you actually want this to be exit 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind this is fine, the Ruby docs on exit were misleading

`PB_DUMP_REQUEST_BYTES=foo.bin protoc foo.proto --plugin=protoc-gen-gem=bin/protoc-gen-ruby --gem_out=.`
will dump the raw proto request bytes generated by protoc for foo.proto to foo.bin

`PB_LOAD_REQUEST_BYTES=foo.bin bin/protoc-gen-ruby`
will read the raw request bytes from foo.bin and print the generated
code (actually it is the code gen response proto, but it is still
readable) to STDOUT
@embark
Copy link
Contributor Author

embark commented Jul 12, 2017

Rebased this! Should be good to go. Will be useful now that we have some bins checked in for functional tests

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants