Don't force debug to true in config file when set via flag

This commit is contained in:
Dane Everitt
2019-12-21 21:10:45 -08:00
parent 536038967a
commit a8e907a0fc
2 changed files with 19 additions and 3 deletions

View File

@@ -250,12 +250,17 @@ func ReadConfiguration(path string) (*Configuration, error) {
}
var _config *Configuration
var _debugViaFlag bool
// Set the global configuration instance.
func Set(c *Configuration) {
_config = c
}
func SetDebugViaFlag(d bool) {
_debugViaFlag = d
}
// Get the global configuration instance.
func Get() *Configuration {
return _config
@@ -383,7 +388,14 @@ func (c *Configuration) WriteToDisk() error {
}
defer f.Close()
b, err := yaml.Marshal(&c)
ccopy := *c
// If debugging is set with the flag, don't save that to the configuration file, otherwise
// you'll always end up in debug mode.
if _debugViaFlag {
ccopy.Debug = false
}
b, err := yaml.Marshal(&ccopy)
if err != nil {
return err
}