github.com/jenspinney/cli@v6.42.1-0.20190207184520-7450c600020e+incompatible/command/flag/health_check_type.go (about) 1 package flag 2 3 import ( 4 "code.cloudfoundry.org/cli/api/cloudcontroller/ccv3/constant" 5 "strings" 6 7 flags "github.com/jessevdk/go-flags" 8 ) 9 10 type HealthCheckType struct { 11 Type constant.HealthCheckType 12 } 13 14 func (HealthCheckType) Complete(prefix string) []flags.Completion { 15 return completions([]string{"http", "port", "process"}, prefix, false) 16 } 17 18 func (h *HealthCheckType) UnmarshalFlag(val string) error { 19 valLower := strings.ToLower(val) 20 switch valLower { 21 case "port", "process", "http": 22 h.Type = constant.HealthCheckType(valLower) 23 default: 24 return &flags.Error{ 25 Type: flags.ErrRequired, 26 Message: `HEALTH_CHECK_TYPE must be "port", "process", or "http"`, 27 } 28 } 29 return nil 30 }