moul / protoc-gen-gotemplate

:open_file_folder: generic protocol generator based on golang's text/template (grpc/protobuf)
https://manfred.life/protoc-gen-gotemplate
MIT License
437 stars 70 forks source link

Add a flag to change which type to iterate over in order to create files #84

Open pmoroney opened 6 years ago

pmoroney commented 6 years ago

I needed to generate a file per message as well as a single file with access to all of the AST. So I added a type flag that you can pass the following options: message: Generate a file per message definition, allows you to create files like {{.Message.Name}}.go.tmpl service: Generate a file per service definition. This was the previous behavior and is now the default. file: Generate a file per .proto file. This allows you to generate per file templates if those proto files have multiple service definitions. none: Generates a single file. This gives you access to .Files which is a slice of all the .File descriptors.

moul commented 6 years ago

Hi @pmoroney,

Can you add an example in the examples directory ? It will be easier to discover the flag features and that example can be used as kind of integration test

Thank you 😊

pmoroney commented 6 years ago

Thanks for your patience, I will get to this as soon as I can :)