Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: show the help message instead of suggesting "go help subcommand" when the --help/-h flag is passed #27580

Open
fatih opened this issue Sep 9, 2018 · 3 comments
Labels
Documentation GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@fatih
Copy link
Member

fatih commented Sep 9, 2018

What version of Go are you using (go version)?

go version go1.11 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

$ go env
GOARCH="amd64"
GOBIN="/Users/fatih/go/bin"
GOCACHE="/Users/fatih/Library/Caches/go-build"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/fatih/go"
GOPROXY=""
GORACE=""
GOROOT="/usr/local/Cellar/go/1.11/libexec"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.11/libexec/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/k_/87syx3r50m93m72hvqj2qqlw0000gn/T/go-build154500786=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

I asked to print the help usage of the command go list:

$ go list --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.

What did you expect to see?

I would like to see the help output instead of suggesting me to run go help list.

# example output I would like to see:
$ go list --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]

List lists the named packages, one per line.
The most commonly-used flags are -f and -json, which control the form
of the output printed for each package. Other list flags, documented below,
control more specific details.
...

What did you see instead?

It suggested to me to run go help list.

I think this is a not very user friendly output. --help (or -h) is a very common flag and is even parsed by the flag package. The go command understand that I'm seeking for a help, instead of suggesting me to run go help list, it should show me the help message.

As an example user case, suppose you run a command and somehow wrote it wrong:

$  go list -f
flag needs an argument: -f
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]
Run 'go help list' for details.

If the go command would support the --help/-h flags, I could press the up key on my keyboard (the shell would show the last executed command) and append the --help flag to see what's wrong:

$  go list -f --help
usage: go list [-f format] [-json] [-m] [list flags] [build flags] [packages]

List lists the named packages, one per line.
The most commonly-used flags are -f and -json, which control the form
of the output printed for each package. Other list flags, documented below,
control more specific details.

...

This example is not only about go list itself, this applies to every single subcommand of the go command. This happens so many times and I think it's counter intuitive to write a comand from scratch (i.e: go help list, go help test, ...). I don't know the origin why --help or -h is permitted and not allowed to be used, but if it's something that can be removed, I suggest we remove the restriction and show the help message instead of suggesting to call go help subcommand (for subcommand related --help messages).

@natefinch
Copy link
Contributor

Yes please, I hate it when software says "Yes, I know what you mean, but you didn't say it right, here's how to say it right", rather than just doing what I ask.

@mvdan
Copy link
Member

mvdan commented Sep 9, 2018

I think the point is to have the output text be small, to not take up the entirety of the user's screen. For example, see #26999.

Perhaps the -h output could be expanded a bit, and then say Run 'go help X' for more details..

@andybons
Copy link
Member

@bcmills @rsc

@andybons andybons added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Sep 25, 2018
@andybons andybons added this to the Unplanned milestone Sep 25, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation GoCommand cmd/go NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

5 participants