Skip to content

Commit

Permalink
cmd/protoc-gen-go: support --help flag
Browse files Browse the repository at this point in the history
When someone has no idea what a binary does, it is convention to
pass the "--help" flag. When done, we should point the user
to the devsite documentation on protoc with protoc-gen-go.

Change-Id: I36289a1ae025b9e12521b34362370aba5235a44b
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/302330
Trust: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
  • Loading branch information
dsnet committed Mar 16, 2021
1 parent 174b9ec commit e471641
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions cmd/protoc-gen-go/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,18 @@ import (
"google.golang.org/protobuf/internal/version"
)

const genGoDocURL = "https://developers.google.com/protocol-buffers/docs/reference/go-generated"
const grpcDocURL = "https://grpc.io/docs/languages/go/quickstart/#regenerate-grpc-code"

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" {
fmt.Fprintf(os.Stdout, "See "+genGoDocURL+" for usage information.\n")
os.Exit(0)
}

var (
flags flag.FlagSet
Expand Down

0 comments on commit e471641

Please sign in to comment.