1
0
mirror of https://github.com/golang/go synced 2024-11-18 11:14:39 -07:00

cmd/godoc: add better user error messages

Fixes golang/go#14280

Change-Id: I3151a17ce9553d0a7fe56c2d614e3a6f6a96344c
Reviewed-on: https://go-review.googlesource.com/36472
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
Hsin Tsao 2017-02-06 16:07:17 -08:00 committed by Brad Fitzpatrick
parent bd1cf89d8f
commit f5bb18ad35

View File

@ -162,8 +162,15 @@ func main() {
playEnabled = *showPlayground playEnabled = *showPlayground
// Check usage: either server and no args, command line and args, or index creation mode // Check usage: server and no args.
if (*httpAddr != "" || *urlFlag != "") && (flag.NArg() > 0) {
fmt.Fprintln(os.Stderr, "can't use -http with args.")
usage()
}
// Check usage: command line args or index creation mode.
if (*httpAddr != "" || *urlFlag != "") != (flag.NArg() == 0) && !*writeIndex { if (*httpAddr != "" || *urlFlag != "") != (flag.NArg() == 0) && !*writeIndex {
fmt.Fprintln(os.Stderr, "missing args.")
usage() usage()
} }