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