From 78efac5f330a33fe8298cca1a516b8752192b8d9 Mon Sep 17 00:00:00 2001 From: Rob Pike Date: Thu, 27 Jun 2013 14:48:27 -0700 Subject: [PATCH] go.tools/cmd/cover: yet another attempt at a usage message (YAAAAUM) for go tool cover R=golang-dev, rsc CC=golang-dev https://golang.org/cl/10710044 --- cmd/cover/cover.go | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/cmd/cover/cover.go b/cmd/cover/cover.go index 10c324617a..b5f2b41c2a 100644 --- a/cmd/cover/cover.go +++ b/cmd/cover/cover.go @@ -31,6 +31,24 @@ import ( "strconv" ) +const usageMessage = "" + + `Usage of 'go tool cover': +Given a coverage profile produced by 'go test -coverprofile=c.out', open +a web browser displaying annotated source code: + go tool cover -html=c.out +The same, but write the generated HTML to a file instead of starting a browser: + go tool cover -html=c.out -o coverage.html +Generate modified source code with coverage annotations (what go test -cover does): + go tool cover -mode=set -var=CoverageVariableName program.go +` + +func usage() { + fmt.Fprintln(os.Stderr, usageMessage) + fmt.Fprintln(os.Stderr, "Flags:") + flag.PrintDefaults() + os.Exit(2) +} + var ( mode = flag.String("mode", "", "coverage mode: set, count, atomic") varVar = flag.String("var", "GoCover", "name of coverage variable to generate") @@ -47,17 +65,6 @@ const ( atomicPackageName = "_cover_atomic_" ) -func usage() { - fmt.Fprintf(os.Stderr, "Usage:\n") - fmt.Fprintf(os.Stderr, " To display annotated source given a coverage profile produced by 'go test -coverprofile=c.out':\n") - fmt.Fprintf(os.Stderr, " go tool cover -html=c.out\n") - fmt.Fprintf(os.Stderr, " To generate modified source code with coverage annotations (what go test -cover does):\n") - fmt.Fprintf(os.Stderr, " go tool cover -mode=set -var=CoverageVariableName program.go\n") - fmt.Fprintf(os.Stderr, "Flags:\n") - flag.PrintDefaults() - os.Exit(2) -} - func main() { flag.Usage = usage flag.Parse()