From e4716418878e35710fb80a258184b63cda66c98b Mon Sep 17 00:00:00 2001 From: Joe Tsai Date: Tue, 16 Mar 2021 12:44:01 -0700 Subject: [PATCH] cmd/protoc-gen-go: support --help flag 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 Reviewed-by: Damien Neil --- cmd/protoc-gen-go/main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmd/protoc-gen-go/main.go b/cmd/protoc-gen-go/main.go index b5150602..0559ee33 100644 --- a/cmd/protoc-gen-go/main.go +++ b/cmd/protoc-gen-go/main.go @@ -21,6 +21,7 @@ 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() { @@ -28,6 +29,10 @@ func main() { 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