Skip to content

Commit e89f7ca

Browse files
committed
add test
1 parent 4a376d5 commit e89f7ca

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Test that --help flag works for go commands
2+
3+
# go build --help shows full help
4+
go build --help
5+
stdout 'usage: go build'
6+
stdout 'Build compiles the packages'
7+
stdout 'For more about specifying packages'
8+
9+
# go install --help shows full help
10+
go install --help
11+
stdout 'usage: go install'
12+
stdout 'Install compiles and installs'
13+
stdout 'For more about specifying packages'
14+
15+
# go get --help shows full help
16+
go get --help
17+
stdout 'usage: go get'
18+
stdout 'Get resolves its command-line arguments'
19+
stdout 'See also: go build, go install'
20+
21+
# go fmt --help shows full help
22+
go fmt --help
23+
stdout 'usage: go fmt'
24+
stdout 'Fmt runs the command'
25+
stdout 'See also: go fix, go vet'
26+
27+
# go run --help shows full help
28+
go run --help
29+
stdout 'usage: go run'
30+
stdout 'Run compiles and runs'
31+
stdout 'See also: go build'
32+
33+
# go run program.go --help should pass --help to the program, not show go run help
34+
go run helpprog.go --help
35+
stdout 'Program help message'
36+
stdout 'Arguments: \[.*helpprog.*--help\]'
37+
38+
-- helpprog.go --
39+
package main
40+
41+
import (
42+
"flag"
43+
"fmt"
44+
"os"
45+
)
46+
47+
func main() {
48+
var help = flag.Bool("help", false, "show help")
49+
flag.Parse()
50+
51+
fmt.Printf("Arguments: %v\n", os.Args)
52+
53+
if *help {
54+
fmt.Println("Program help message")
55+
}
56+
}

0 commit comments

Comments
 (0)