File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -386,6 +386,10 @@ def main():
386
386
request = plugin .CodeGeneratorRequest ()
387
387
request .ParseFromString (data )
388
388
389
+ dump_file = os .getenv ("DUMP_FILE" )
390
+ if dump_file :
391
+ dump_request (dump_file , request )
392
+
389
393
# Create response
390
394
response = plugin .CodeGeneratorResponse ()
391
395
@@ -399,5 +403,16 @@ def main():
399
403
sys .stdout .buffer .write (output )
400
404
401
405
406
+ def dump_request (dump_file : str , request : CodeGeneratorRequest ):
407
+ """
408
+ For developers: Supports running plugin.py standalone so its possible to debug it.
409
+ Run protoc (or generate.py) with DUMP_FILE="yourfile.bin" to write the request to a file.
410
+ Then run plugin.py from your IDE in debugging mode, and redirect stdin to the file.
411
+ """
412
+ with open (str (dump_file ), "wb" ) as fh :
413
+ sys .stderr .write (f"\033 [31mWriting: { dump_file } \033 [0m\n " )
414
+ fh .write (request .SerializeToString ())
415
+
416
+
402
417
if __name__ == "__main__" :
403
418
main ()
You can’t perform that action at this time.
0 commit comments