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
This commit is contained in:
Rob Pike 2013-06-27 14:48:27 -07:00
Родитель 69c297407f
Коммит 78efac5f33
1 изменённых файлов: 18 добавлений и 11 удалений

Просмотреть файл

@ -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()