Skip to content

Commit 6e6c6da

Browse files
committed
feat: Add version and help flag
1 parent b64b4ea commit 6e6c6da

File tree

5 files changed

+19
-4
lines changed

5 files changed

+19
-4
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,4 @@
2121
go.work
2222
.idea/
2323

24+
dist/

.goreleaser.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ builds:
88
env:
99
- CGO_ENABLED=0
1010
ldflags:
11-
- -s
11+
- -s -X main.version={{ .Version }}
1212
goos:
1313
- linux
1414
- darwin

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ module github.com/pubg/protoc-gen-debug
22

33
go 1.20
44

5-
require google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500 // indirect
5+
require google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
2+
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
23
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
4+
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
35
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
46
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
5-
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
6-
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
77
google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500 h1:7y2/WECm0zxQchjsPsWLAajGJ77KApK/0JpIaBOeDvk=
88
google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=

main.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package main
22

33
import (
44
"flag"
5+
"fmt"
6+
"os"
57
"strings"
68

79
"google.golang.org/protobuf/compiler/protogen"
@@ -21,7 +23,19 @@ type PluginOptions struct {
2123
Parameter string
2224
}
2325

26+
var version string = "develop"
27+
2428
func main() {
29+
if len(os.Args) == 2 {
30+
if os.Args[1] == "--version" {
31+
fmt.Println(version)
32+
} else if os.Args[1] == "--help" {
33+
fmt.Println("USAGE:")
34+
fmt.Println(" protoc-gen-debug --version : print version")
35+
}
36+
return
37+
}
38+
2539
var flags flag.FlagSet
2640
opts := protogen.Options{
2741
ParamFunc: flags.Set,

0 commit comments

Comments
 (0)