github.com/dcarley/cf-cli@v6.24.1-0.20170220111324-4225ff346898+incompatible/command/flag/color.go (about) 1 package flag 2 3 import ( 4 "strings" 5 6 flags "github.com/jessevdk/go-flags" 7 ) 8 9 type Color struct { 10 Color bool 11 } 12 13 func (c Color) Complete(prefix string) []flags.Completion { 14 return completions([]string{"true", "false"}, prefix) 15 } 16 17 func (c *Color) UnmarshalFlag(val string) error { 18 switch strings.ToLower(val) { 19 case "true": 20 c.Color = true 21 case "false": 22 c.Color = false 23 default: 24 return &flags.Error{ 25 Type: flags.ErrRequired, 26 Message: `COLOR must be "true" or "false"`, 27 } 28 } 29 30 return nil 31 }