Skip to content

Commit 0fd0b20

Browse files
committed
Add --version flag for protoc-gen-js
This flag is intended to be used directly against protoc-gen-js (e.g. protoc-gen-js --version) as opposed to being passed to the plugin via protoc.
1 parent 208f17b commit 0fd0b20

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

MODULE.bazel.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generator/protoc-gen-js.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,20 @@
2929
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3030

3131
#include <google/protobuf/compiler/plugin.h>
32+
#include <iostream>
33+
#include <string>
3234

3335
#include "generator/js_generator.h"
3436

37+
const char* kVersion = "4.0.0";
38+
3539
int main(int argc, char** argv) {
40+
for (int i = 1; i < argc; ++i) {
41+
if (std::string(argv[i]) == "--version") {
42+
std::cout << "protoc-gen-js version " << kVersion << std::endl;
43+
return 0;
44+
}
45+
}
3646
std::unique_ptr<google::protobuf::compiler::CodeGenerator> generator(
3747
new google::protobuf::compiler::js::Generator());
3848
return google::protobuf::compiler::PluginMain(argc, argv, generator.get());

0 commit comments

Comments
 (0)