]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: do not print entire help text for unrecognized flag
authorRuss Cox <rsc@golang.org>
Sat, 4 Nov 2017 17:14:19 +0000 (13:14 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 6 Nov 2017 14:35:12 +0000 (14:35 +0000)
I typed 'go list -josn' without realizing I'd mistyped json, and I was confused for
quite a while as to why I was staring at the 'go help json' text: the actual problem
(a missing flag) scrolls far off the screen. If people want the full text, they can
easily ask for it, but don't drown the important bit - unrecognized flag or other
improper usage - with pages of supporting commentary. The help text does not
help people who just need to be told about a typo.

Change-Id: I179c431baa831e330f3ee495ce0a5369319962d5
Reviewed-on: https://go-review.googlesource.com/76013
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/cmd/go/internal/base/base.go

index aff33f70d8deb3394e708bf2c20e0edeb840087e..286efbc04104177167afed208168662f1efba1d8 100644 (file)
@@ -62,8 +62,8 @@ func (c *Command) Name() string {
 }
 
 func (c *Command) Usage() {
-       fmt.Fprintf(os.Stderr, "usage: %s\n\n", c.UsageLine)
-       fmt.Fprintf(os.Stderr, "%s\n", strings.TrimSpace(c.Long))
+       fmt.Fprintf(os.Stderr, "usage: %s\n", c.UsageLine)
+       fmt.Fprintf(os.Stderr, "Run 'go help %s' for details.\n", c.Name())
        os.Exit(2)
 }