-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
43 lines (38 loc) · 949 Bytes
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package main
import (
"errors"
"flag"
"fmt"
"github.com/GodWY/protoc-gen-hip/internal_genhi"
"github.com/GodWY/protoc-gen-hip/version"
"os"
"path/filepath"
"google.golang.org/protobuf/compiler/protogen"
)
func main() {
if len(os.Args) == 2 && os.Args[1] == "--version" {
fmt.Fprintf(os.Stdout, "%v %v\n", filepath.Base(os.Args[0]), version.String())
os.Exit(0)
}
if len(os.Args) == 2 && os.Args[1] == "--help" {
os.Exit(0)
}
var (
flags flag.FlagSet
plugins = flags.String("plugins", "", "deprecated option")
)
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
if *plugins != "" {
return errors.New("protoc-gen-go: plugins are not supported; use 'protoc --go-grpc_out=...' to generate gRPC\n\n")
}
for _, f := range gen.Files {
if f.Generate {
internal_genhi.GenerateFile(gen, f)
}
}
gen.SupportedFeatures = internal_genhi.SupportedFeatures
return nil
})
}