-
Notifications
You must be signed in to change notification settings - Fork 12
/
flags.go
152 lines (131 loc) · 3.24 KB
/
flags.go
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
package cli
import "github.com/urfave/cli"
const (
// DebugEnvKey ...
DebugEnvKey = "STEPMAN_DEBUG"
// LogLevelEnvKey ...
LogLevelEnvKey = "LOGLEVEL"
// CollectionPathEnvKey ...
CollectionPathEnvKey = "STEPMAN_COLLECTION"
// HelpKey ...
HelpKey = "help"
helpKeyShort = "h"
// VersionKey ...
VersionKey = "version"
versionKeyShort = "v"
// CollectionKey ...
CollectionKey = "collection"
collectionKeyShort = "c"
// LocalCollectionKey ...
LocalCollectionKey = "local"
// CopySpecJSONKey ...
CopySpecJSONKey = "copy-spec-json"
// DebugKey ...
DebugKey = "debug"
debugKeyShort = "d"
// LogLevelKey ...
LogLevelKey = "loglevel"
logLevelKeyShort = "l"
// IDKey ...
IDKey = "id"
idKeyShort = "i"
// PathKey ...
PathKey = "path"
pathKeyShort = "p"
// CopyYMLKey ...
CopyYMLKey = "copyyml"
copyYMLKeyShort = "y"
// UpdateKey ...
UpdateKey = "update"
updateKeyShort = "u"
// TagKey ...
TagKey = "tag"
tagKeyShort = "t"
// GitKey ...
GitKey = "git"
gitKeyShort = "g"
// StepIDKey ...
StepIDKey = "stepid"
stepIDKeyShort = "s"
// ShortKey ...
ShortKey = "short"
// ToolMode ...
ToolMode = "toolmode"
// FormatKey ...
FormatKey = "format"
formatKeyShort = "f"
// OutputFormatRaw ...
OutputFormatRaw = "raw"
// OutputFormatJSON ...
OutputFormatJSON = "json"
// StepYMLKey ...
StepYMLKey = "step-yml"
)
var (
// App flags
flLogLevel = cli.StringFlag{
Name: LogLevelKey + ", " + logLevelKeyShort,
Value: "info",
Usage: "Log level (options: debug, info, warn, error, fatal, panic).",
EnvVar: LogLevelEnvKey,
}
flags = []cli.Flag{
flLogLevel,
}
// Command flags
flCollection = cli.StringFlag{
Name: CollectionKey + ", " + collectionKeyShort,
Usage: "Collection of step.",
EnvVar: CollectionPathEnvKey,
}
flLocalCollection = cli.BoolFlag{
Name: LocalCollectionKey,
Usage: "[Deprecated!!!][Use 'file://' in steplib uri instead] Allow the --collection to be a local path.",
}
flCopySpecJSON = cli.StringFlag{
Name: CopySpecJSONKey,
Usage: "If setup succeeds copy the generates spec.json to this path.",
}
flID = cli.StringFlag{
Name: IDKey + ", " + idKeyShort,
Usage: "Step id.",
}
flVersion = cli.StringFlag{
Name: VersionKey + ", " + versionKeyShort,
Usage: "Step version.",
}
flUpdate = cli.BoolFlag{
Name: UpdateKey + ", " + updateKeyShort,
Usage: "If flag is set, and collection doesn't contains the specified step, the collection will updated.",
}
flTag = cli.StringFlag{
Name: TagKey + ", " + tagKeyShort,
Usage: "Git (version) tag.",
}
flGit = cli.StringFlag{
Name: GitKey + ", " + gitKeyShort,
Usage: "Git clone url of the step repository.",
}
flStepID = cli.StringFlag{
Name: StepIDKey + ", " + stepIDKeyShort,
Usage: "ID of the step.",
}
flFormat = cli.StringFlag{
Name: FormatKey + ", " + formatKeyShort,
Usage: "Output format (options: raw, json).",
}
flToolMode = cli.BoolFlag{
Name: ToolMode,
Usage: "Stepman called as tool.",
}
)
func initHelpAndVersionFlags() {
cli.HelpFlag = cli.BoolFlag{
Name: HelpKey + ", " + helpKeyShort,
Usage: "Show help.",
}
cli.VersionFlag = cli.BoolFlag{
Name: VersionKey + ", " + versionKeyShort,
Usage: "Print the version.",
}
}