diff options
| author | Jeff Carr <[email protected]> | 2025-10-15 00:25:32 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-15 00:25:32 -0500 |
| commit | 6bf6cd03a651013a327d31427d0366cd8aa1c8de (patch) | |
| tree | 5d744cc6ab2c7a4569379a0522371e8e2862e03a | |
| parent | 97a695752040ccf96335c5e593bd9856a61a5fb6 (diff) | |
try out an If(key) functionv0.0.25
| -rw-r--r-- | exit.go | 5 | ||||
| -rw-r--r-- | verbose.go | 31 |
2 files changed, 32 insertions, 4 deletions
@@ -4,13 +4,12 @@ package config // see how this turns out import ( + "fmt" "os" - - "go.wit.com/log" ) // todo: figure out how to pass this back to argv func BadExit(reason string, err error) { - log.Exit("lib/config exiting here", reason, err) + fmt.Println("lib/config bad exit. no app callback here. FIXME", reason, err) os.Exit(-1) } @@ -7,8 +7,36 @@ func Verbose() bool { // always use the config file value first if configPB != nil { found := configPB.FindByKey("Verbose") + if found == nil { + // Verbose isn't in the config. do nothing here + } else { + // return what the config file has + // fmt.Println("returning from the config:" + found.Value) + if found.Value == "true" { + return true + } + return false + } + } - if found != nil { + // nothing in the config file. check argv + for _, v := range argv { + if v == "--verbose" { + return true + } + } + return false +} + +func If(key string) bool { + // always use the config file value first + if configPB != nil { + found := configPB.FindByKey(key) + if found == nil { + // Verbose isn't in the config. do nothing here + } else { + // return what the config file has + // fmt.Println("returning from the config:" + found.Value) if found.Value == "true" { return true } @@ -17,6 +45,7 @@ func Verbose() bool { } // nothing in the config file. check argv + // todo: turn key to lowercase and check here for _, v := range argv { if v == "--verbose" { return true |
