mirror of
https://github.com/minio/minio.git
synced 2024-12-27 15:45:55 -05:00
32 lines
696 B
Go
32 lines
696 B
Go
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 ""
|
|
}
|