-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathhelp_test.go
More file actions
75 lines (64 loc) · 1.28 KB
/
help_test.go
File metadata and controls
75 lines (64 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package cli
import (
"bytes"
"testing"
)
func TestHelpShowVersion(t *testing.T) {
app := &App{
Name: "app",
Version: "1.2.3",
BuildInfo: &BuildInfo{
Timestamp: "Sat May 13 19:53:08 UTC 2017",
GitBranch: "master",
GitCommit: "320279c",
GitRevCount: "1234",
},
}
// reset
helpWriter = new(bytes.Buffer)
showVersion(app)
}
func TestHelpShowHelp(t *testing.T) {
app := NewApp()
app.Name = "app"
app.Version = "1.1.1"
app.Usage = "demo app"
app.Flags = []*Flag{
{
Name: "i, input",
Usage: "input file",
Placeholder: "file",
},
{
Name: "o, output",
Usage: "output file",
},
}
app.Commands = []*Command{
{
Name: "build",
Usage: "build project",
Flags: []*Flag{
{
Name: "debug",
Usage: "enable debug",
IsBool: true,
},
},
SeeAlso: "https://github.com/subchen/go-cli#build\nhttps://github.com/subchen/go-cli#build2",
},
{
Name: "release",
Usage: "release project",
},
}
app.SeeAlso = `https://github.com/subchen
https://github.com/yingzhuo`
// reset
helpWriter = new(bytes.Buffer)
ctx1 := newAppHelpContext("app", app)
showHelp(ctx1)
ctx2 := newCommandHelpContext("app build", app.Commands[0], app)
showHelp(ctx2)
}