blob: 0a911e8b34ea5e825403154bc5640221bb228d89 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
// Copyright 2025 WIT.COM Inc Licensed GPL 3.0
package tree
// functions to import and export the protobuf
// data to and from config files
import (
"fmt"
"go.wit.com/lib/config"
)
// load the ~/.config/forge/ files
func configLoad() *ToolkitConfigs {
cfg := NewToolkitConfigs()
cfg.Filename = config.MakeConfigFilename("forge", "toolkit")
err := config.ReLoad(cfg)
if err != nil {
// first time user. insert a sample option
cfg.sampleConfig()
}
return cfg
}
// makes a sample config (and saves it)
func (cfg *ToolkitConfigs) sampleConfig() *ToolkitConfigs {
new1 := new(ToolkitConfig)
new1.Plugin = "tree"
new1.Name = "test"
new1.Value = "apple"
cfg.Append(new1)
fmt.Println("first time user. adding an example config file with", cfg.Len(), "options")
return cfg
}
|