You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
minio/vendor/github.com/nsqio/go-nsq/config_flag.go

31 lines
696 B

package nsq
import (
"strings"
)
// ConfigFlag wraps a Config and implements the flag.Value interface
type ConfigFlag struct {
Config *Config
}
// Set takes a comma separated value and follows the rules in Config.Set
// using the first field as the option key, and the second (if present) as the value
func (c *ConfigFlag) Set(opt string) (err error) {
parts := strings.SplitN(opt, ",", 2)
key := parts[0]
switch len(parts) {
case 1:
// default options specified without a value to boolean true
err = c.Config.Set(key, true)
case 2:
err = c.Config.Set(key, parts[1])
}
return
}
// String implements the flag.Value interface
func (c *ConfigFlag) String() string {
return ""
}