summaryrefslogtreecommitdiff
path: root/config.Save.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-20 05:50:38 -0500
committerJeff Carr <[email protected]>2025-10-20 05:50:38 -0500
commit8a24584262a90956e012cee7b03c8c2b9f4b794c (patch)
tree8b7d0afd04e717d7c07da5eb2894debd74ec2307 /config.Save.go
parentb6e93c08d601a7a6c27a0fdcdf98f6cb7dc9ccd8 (diff)
reworking this to make it more sane. hopefully.
Diffstat (limited to 'config.Save.go')
-rw-r--r--config.Save.go35
1 files changed, 20 insertions, 15 deletions
diff --git a/config.Save.go b/config.Save.go
index c5aaeb7..1f1736f 100644
--- a/config.Save.go
+++ b/config.Save.go
@@ -3,6 +3,7 @@ package config
import (
"os"
"path/filepath"
+ "strings"
"sync"
)
@@ -38,33 +39,37 @@ func Get(flag string) string {
if configPB == nil {
return ""
}
- found := configPB.FindByKey(flag)
- if found == nil {
+ c := findByLower(flag)
+ if c == nil {
return ""
}
- return found.Value
+
+ return c.Value
+}
+
+func findByLower(lookingFor string) *Config {
+ for c := range configPB.IterAll() {
+ if strings.ToLower(c.Key) == strings.ToLower(lookingFor) {
+ return c
+ }
+ }
+ return nil
}
-func GetPanic(flag string) string {
+func True(flag string) bool {
saveMu.Lock()
defer saveMu.Unlock()
if configPB == nil {
- configPanic(flag)
+ return false
}
found := configPB.FindByKey(flag)
if found == nil {
- configPanic(flag)
+ return false
}
- return found.Value
-}
-
-func configPanic(varname string) {
- saveMu.Lock()
- defer saveMu.Unlock()
- if configPB == nil {
- panic("config file is nil")
+ if strings.ToLower(found.Value) == "true" {
+ return true
}
- panic("config name '" + varname + "' not found")
+ return false
}
func Set(key string, newValue string) error {