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 <joetsai@digital-static.net>
Reviewed-by: Damien Neil <dneil@google.com>
This commit is contained in:
Joe Tsai 2021-03-16 12:44:01 -07:00
parent 174b9ecfe3
commit e471641887

View File

@ -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