I don't know of any existing tool for doing this, but you could try
something like this:
1. Run "protoc --descriptor_set_out=descriptors.out ..." to parse each
.proto file and serialize the descriptors to a file.
2. Write a simple program to read the serialized descriptors from step 1
and determine which fields you need to edit.
3. Use a regex search-and-replace to edit the necessary fields in the
original .proto files. This step may be the hardest because I can imagine
it may be tough to come up with a regex that can handle all formatting
variations, but you could also try passing --include_source_info in step 1
and that would give you information about the location of each field in the
source .proto file.

On Fri, May 4, 2018 at 12:04 PM Mark Hoffman <[email protected]> wrote:

> Hi,
>
> I have the tasks of retrofitting a large repo of .proto files to include a
> field option with a default value to every field, except for enums. We
> can't assume if the field option is not present that it has a default, for
> security reasons. Before I go off an write a parser to handle this one time
> task, I was justing wondering something might already exist. One other
> issue, I need to preserve the comments in the .proto files.
>
> Thanks.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Protocol Buffers" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To post to this group, send email to [email protected].
> Visit this group at https://groups.google.com/group/protobuf.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Protocol Buffers" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/protobuf.
For more options, visit https://groups.google.com/d/optout.

Reply via email to