From 96378c70293b7367f43e630a8d334c19f701b4db Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 14 Oct 2025 00:49:35 -0500 Subject: make config.Set(key, value) --- errors.go | 5 +++++ flags.go | 19 ++++++++++++------- init.go | 4 ---- 3 files changed, 17 insertions(+), 11 deletions(-) create mode 100644 errors.go diff --git a/errors.go b/errors.go new file mode 100644 index 0000000..807386d --- /dev/null +++ b/errors.go @@ -0,0 +1,5 @@ +package config + +import "errors" + +var NotInitialized error = errors.New("your application config not initialized") diff --git a/flags.go b/flags.go index d827f7e..31d6801 100644 --- a/flags.go +++ b/flags.go @@ -11,13 +11,18 @@ func Get(flag string) string { return found.Value } -func GetError(flag string) error { - return nil -} - -func Set(flag string) { -} +func Set(key string, newValue string) error { + if configPB == nil { + return NotInitialized + } + found := configPB.FindByKey(key) + if found != nil { + found.Value = newValue + } -func SetError(flag string) error { + newvar := new(Config) + newvar.Key = key + newvar.Value = newValue + configPB.Append(newvar) return nil } diff --git a/init.go b/init.go index eb5afbe..93ebeab 100644 --- a/init.go +++ b/init.go @@ -66,10 +66,6 @@ func makeNewConfigFile(appname string) error { newvar.Value = "protobufs are neat" configPB.Clone(newvar) - newvar.Key = "Verbose" - newvar.Value = "true" - configPB.Clone(newvar) - // writes the config file to disk err = Save() return err -- cgit v1.2.3