Skip to content

Instantly share code, notes, and snippets.

@remyleone
Created February 27, 2020 08:36
Show Gist options
  • Save remyleone/54725a5be6d152a406929036512981e4 to your computer and use it in GitHub Desktop.
Save remyleone/54725a5be6d152a406929036512981e4 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
import sys
import pdb
from google.protobuf.compiler import plugin_pb2 as plugin
def generate_code(request, response):
with open("request.txt", "w") as f:
f.write(str(request))
if __name__ == '__main__':
# Read request message from stdin
data = sys.stdin.read()
# Parse request
request = plugin.CodeGeneratorRequest()
request.ParseFromString(data)
# Create response
response = plugin.CodeGeneratorResponse()
# Generate code
generate_code(request, response)
# Serialise response message
output = response.SerializeToString()
# Write to stdout
sys.stdout.write(output)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment