cmd/pack: print error along with usage

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
This commit is contained in:
Russ Cox 2014-04-15 20:05:56 -04:00
parent c8ef6776e4
commit 22505cd2a1
1 changed files with 4 additions and 0 deletions

View 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 {