-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
43 lines (33 loc) · 978 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
// SPDX-FileCopyrightText: Copyright 2021 The protobuf-tools Authors
// SPDX-License-Identifier: BSD-3-Clause
// Command protoc-gen-deepcopy is a plugin for protoc which generates DeepCopyInto(), DeepCopy() and DeepCopyInterface() functions for .pb.go types.
package main
import (
"flag"
"fmt"
"google.golang.org/protobuf/compiler/protogen"
"github.com/protobuf-tools/protoc-gen-deepcopy/deepcopy"
)
// version is the this binary vesion.
// TODO(zchee): parse module version itself.
var version = "v0.0.3"
func main() {
showVersion := flag.Bool("version", false, "print the version and exit")
flag.Parse()
if *showVersion {
fmt.Printf("protoc-gen-deepcopy %s\n", version)
return
}
var flags flag.FlagSet
protogen.Options{
ParamFunc: flags.Set,
}.Run(func(gen *protogen.Plugin) error {
gen.SupportedFeatures = deepcopy.SupportedFeatures
for _, f := range gen.Files {
if f.Generate {
deepcopy.GenerateFile(gen, f)
}
}
return nil
})
}