1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-19 21:18:07 +02:00

38 lines
760 B
Go
Raw Normal View History

2021-02-17 17:14:47 +08:00
package main
import (
"flag"
"fmt"
"google.golang.org/protobuf/compiler/protogen"
"google.golang.org/protobuf/types/pluginpb"
)
2021-07-18 20:15:52 +08:00
const version = "v2.0.1"
2021-02-17 17:14:47 +08:00
func main() {
showVersion := flag.Bool("version", false, "print the version and exit")
2021-06-14 11:43:22 +08:00
omitempty := flag.Bool("omitempty", true, "omit if google.api is empty")
2021-02-17 17:14:47 +08:00
flag.Parse()
if *showVersion {
fmt.Printf("protoc-gen-go-http %v\n", version)
return
}
2021-06-14 11:43:22 +08:00
//var flags flag.FlagSet
2021-02-17 17:14:47 +08:00
protogen.Options{
2021-06-14 11:43:22 +08:00
ParamFunc: flag.CommandLine.Set,
2021-02-17 17:14:47 +08:00
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = uint64(pluginpb.CodeGeneratorResponse_FEATURE_PROTO3_OPTIONAL)
for _, f := range gen.Files {
if !f.Generate {
continue
}
2021-06-14 11:43:22 +08:00
generateFile(gen, f, *omitempty)
2021-02-17 17:14:47 +08:00
}
return nil
})
}