-
Notifications
You must be signed in to change notification settings - Fork 13
/
step.go
53 lines (44 loc) · 940 Bytes
/
step.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
package deploy
import (
"strings"
"github.com/ActiveState/cli/internal/locale"
)
// Step is the --step flag for the --deploy command, it implements captain.FlagMarshaler
type Step int
const (
UnsetStep Step = iota
InstallStep
ConfigureStep
SymlinkStep
ReportStep
)
var StepMap = map[Step]string{
UnsetStep: "unset",
InstallStep: "install",
ConfigureStep: "configure",
SymlinkStep: "symlink",
ReportStep: "report",
}
func (t Step) String() string {
for k, v := range StepMap {
if k == t {
return v
}
}
return StepMap[UnsetStep]
}
func (t *Step) Set(value string) error {
for k, v := range StepMap {
if v == value && k != UnsetStep {
*t = k
return nil
}
}
return locale.NewInputError("err_invalid_step", "",
value,
strings.Join([]string{InstallStep.String(), ConfigureStep.String(), ReportStep.String()}, ", "), // allowed values
)
}
func (t *Step) Type() string {
return "step"
}