diff options
| author | Jeff Carr <[email protected]> | 2025-10-21 07:52:15 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-21 07:52:15 -0500 |
| commit | d7309a78203a1b6219db51cb6c4d6f1eaa47deec (patch) | |
| tree | 4558d86c3bc408b4f696ff86168648eb5856bc8f /init.go | |
| parent | 7e8d2b3d75abb4c59b5b29bd2af730cae9d6f1b8 (diff) | |
use smater funcs()
Diffstat (limited to 'init.go')
| -rw-r--r-- | init.go | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -3,6 +3,7 @@ package forgepb import ( + "errors" "os" "os/user" "path/filepath" @@ -73,8 +74,7 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { // always define if ENV.Get("gopath") == "" { gopath := filepath.Join(ENV.Get("homedir"), "go/src") - ENV.Set("gopath", gopath) - ENV.Save() + ENV.SetGlobal("lib/forgepb", "gopath", gopath) } // always set f.mode @@ -91,18 +91,16 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { // todo: play with these / determine good values based on user's machine if cobol.Int(ENV.Get("RillX")) == 0 { - ENV.Set("RillX", "10") - ENV.Save() + ENV.SetGlobal("lib/forgepb", "RillX", "10") } if cobol.Int(ENV.Get("RillY")) == 0 { - ENV.Set("RillY", "20") + ENV.SetGlobal("lib/forgepb", "RillY", "20") ENV.Save() } // create an initial repos.pb file // panic() here? // warning? // (probably not. it's just the repos.pb cache file - f.Repos = gitpb.NewRepos() - err := f.Repos.CacheLoad() // loads the file from ~/.cache/forge/repos.pb + err := f.reposCacheLoad() // loads the file from ~/.cache/forge/repos.pb if err == nil { log.Printf("forge loaded %s file with len(%d) repos\n", f.Repos.Filename, f.Repos.Len()) } else { @@ -112,6 +110,16 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { return f } +func (f *Forge) reposCacheLoad() error { + if f.Repos != nil { + return errors.New("already loaded") + } + f.Repos = gitpb.NewRepos() + err := config.LoadAppnameCache(f.Repos, "forge") + ENV.SetGlobal("lib/forgepb", "ReposPB", f.Repos.Filename) + return err +} + func (f *Forge) SetConfigSave(b bool) { config.SetChanged("forge", b) } |
