Skip to content

Commit

Permalink
feat: Add version and help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
uanid committed Sep 8, 2023
1 parent b64b4ea commit 6e6c6da
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
go.work
.idea/

dist/
2 changes: 1 addition & 1 deletion .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ builds:
env:
- CGO_ENABLED=0
ldflags:
- -s
- -s -X main.version={{ .Version }}
goos:
- linux
- darwin
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ module github.com/pubg/protoc-gen-debug

go 1.20

require google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500 // indirect
require google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8=
google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500 h1:7y2/WECm0zxQchjsPsWLAajGJ77KApK/0JpIaBOeDvk=
google.golang.org/protobuf v1.31.1-0.20230727123859-6d0a5dbd9500/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I=
14 changes: 14 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package main

import (
"flag"
"fmt"
"os"
"strings"

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

var version string = "develop"

func main() {
if len(os.Args) == 2 {
if os.Args[1] == "--version" {
fmt.Println(version)
} else if os.Args[1] == "--help" {
fmt.Println("USAGE:")
fmt.Println(" protoc-gen-debug --version : print version")
}
return
}

var flags flag.FlagSet
opts := protogen.Options{
ParamFunc: flags.Set,
Expand Down

0 comments on commit 6e6c6da

Please sign in to comment.