-
Notifications
You must be signed in to change notification settings - Fork 2
/
flag.go
55 lines (46 loc) · 1.49 KB
/
flag.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
package flag
import (
"github.com/spf13/pflag"
)
//Constant flags used in CLI
const (
DoRunParallel = "parallel"
NoGenerate = "no-generate"
ReRun = "re-run"
DryRun = "dry-run"
Verbose = "verbose"
ConfigurationFile = "conf"
)
//Init initializes all flags
func Init(flags *pflag.FlagSet) {
AddVerboseFlag(flags)
AddConfFileFlag(flags)
AddDryRunFlag(flags)
AddReRunFlag(flags)
AddNoGenFlag(flags)
AddRunParFlag(flags)
}
//AddVerboseFlag flag
func AddVerboseFlag(flags *pflag.FlagSet) {
flags.BoolP(Verbose, "v", false, "print verbosely")
}
//AddConfFileFlag flag
func AddConfFileFlag(flags *pflag.FlagSet) {
flags.StringP(ConfigurationFile, "c", "mozart-sample.yaml", "configuration yaml file needed for application")
}
//AddDryRunFlag flag
func AddDryRunFlag(flags *pflag.FlagSet) {
flags.BoolP(DryRun, "d", false, "(optional) shows what scripts will run, but does not run the scripts")
}
//AddReRunFlag flag
func AddReRunFlag(flags *pflag.FlagSet) {
flags.BoolP(ReRun, "r", false, "(optional) re-run script from initial state, ignoring previously saved state")
}
//AddNoGenFlag flag
func AddNoGenFlag(flags *pflag.FlagSet) {
flags.BoolP(NoGenerate, "n", false, "(optional) do not generate scripts as part of execute, instead use the ones in generated folder. Useful for running local change to the scripts")
}
//AddRunParFlag flag
func AddRunParFlag(flags *pflag.FlagSet) {
flags.BoolP(DoRunParallel, "p", false, "(optional) Run all scripts in parallel")
}