github.com/thanhphan1147/cloudfoundry-cli@v7.1.0+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  	Value string
    11  	IsSet bool
    12  }
    13  
    14  func (Color) Complete(prefix string) []flags.Completion {
    15  	return completions([]string{"true", "false"}, prefix, false)
    16  }
    17  
    18  func (c *Color) UnmarshalFlag(val string) error {
    19  	switch strings.ToLower(val) {
    20  	case "true":
    21  		c.Value = "true"
    22  		c.IsSet = true
    23  	case "false":
    24  		c.Value = "false"
    25  		c.IsSet = true
    26  	default:
    27  		return &flags.Error{
    28  			Type:    flags.ErrRequired,
    29  			Message: `COLOR must be "true" or "false"`,
    30  		}
    31  	}
    32  
    33  	return nil
    34  }