Hmm, I think both of these are problematic:
- Embedding the JSON in every CodeGeneratorRequest seems wasteful when most plugins don't need the JSON. I don't like saying "well, who cares, it's just build time" as this waste tends to add up and iteration speed maters when developing.
- Requiring a different user-visible command-line is exposing implementation details and means that it will be hard for a plugin to switch to capnp format later on.
Here's a different idea: we build it as an adapter. The capnp tool itself remains unchanged, but we offer another binary called capnp-json-adapter. This binary reads in a CodeGeneratorRequest in capnp format, converts it to JSON, then execs some other binary and writes the JSON to the new program's stdin. You use the adapter by symlinking it as your plugin. So if you are making a plugin for, say, Scala, you symlink capnpc-scala to capnp-json-adapter. The adapter looks at its argv[0] to find out what plugin you were trying to execute, and then executes capnp-json-<name>, e.g. capnp-json-scala in this case.
This whole thing -- including the json codec -- can in theory be implemented as a separate project, avoiding bloat and simplifying project management (no need to wait for me to review changes).
Thoughts?
-Kenton