From d141b4d308f71418e8d43a58c2e04f9560db3092 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 25 Mar 2025 07:28:06 -0500 Subject: save the toolkit config options --- init.go | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'init.go') diff --git a/init.go b/init.go index 6bb8efd..8122cca 100644 --- a/init.go +++ b/init.go @@ -72,3 +72,26 @@ func (t *TreeInfo) ConfigFind(n string) (string, error) { } return "", fmt.Errorf("toolkit config %s not found", n) } + +func (t *TreeInfo) ConfigSave(o *ToolkitConfig) { + t.configInsert(o) + t.config.configSave() +} + +// update the config option value (or append if new record) +func (t *TreeInfo) configInsert(newr *ToolkitConfig) { + all := t.config.All() // get the list of repos + for all.Scan() { + r := all.Next() + if t.PluginName != r.Plugin { + // option isn't for this plugin + continue + } + if newr.Name == r.Name { + // found the record! + r.Value = newr.Value + return + } + } + t.config.Append(newr) +} -- cgit v1.2.3