diff --git a/client/config/config.go b/client/config/config.go index ec515ab98..34e75fe8c 100644 --- a/client/config/config.go +++ b/client/config/config.go @@ -56,7 +56,7 @@ func NewConfig() Config { return config } -// GetOpt returns the specified configuration value or "". +// Read returns the specified configuration value or "". func (c *Config) Read(id string) string { val, ok := c.Options[id] if !ok { @@ -64,3 +64,13 @@ func (c *Config) Read(id string) string { } return val } + +// ReadDefault returns the specified configuration value, or the specified +// default value if none is set. +func (c *Config) ReadDefault(id string, defaultValue string) string { + val := c.Read(id) + if val != "" { + return val + } + return defaultValue +}