]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/pack: print error along with usage
authorRuss Cox <rsc@golang.org>
Wed, 16 Apr 2014 00:05:56 +0000 (20:05 -0400)
committerRuss Cox <rsc@golang.org>
Wed, 16 Apr 2014 00:05:56 +0000 (20:05 -0400)
My cmd/go got in a weird state where it started invoking pack grcP.
Change pack to print a 1-line explanation of the usage problem
before the generic usage message.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/87770047

src/cmd/pack/pack.go

index ce73164171cbabdf194cc0767e9fddd52997c1a7..468104deb6c0d7bceb5006a0b817a185de6cba35 100644 (file)
@@ -52,6 +52,8 @@ func main() {
        log.SetPrefix("pack: ")
        // need "pack op archive" at least.
        if len(os.Args) < 3 {
+               log.Print("not enough arguments")
+               fmt.Fprintln(os.Stderr)
                usage()
        }
        setOp(os.Args[1])
@@ -75,6 +77,8 @@ func main() {
                ar = archive(os.Args[2], os.O_RDONLY, os.Args[3:])
                ar.scan(ar.extractContents)
        default:
+               log.Printf("invalid operation %q", os.Args[1])
+               fmt.Fprintln(os.Stderr)
                usage()
        }
        if len(ar.files) > 0 {