diff options
| author | Jeff Carr <[email protected]> | 2025-10-21 04:49:06 -0500 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2025-10-21 04:49:06 -0500 |
| commit | c9fae2681ba33612fca2418523964cfc7b92cac1 (patch) | |
| tree | 471ed9830399c5f36210f3ceff6c0b90c41d42bd /init.go | |
| parent | 69b5038c58e6a8487f22aeaf28eddec5c785c283 (diff) | |
starting to limp back to working
Diffstat (limited to 'init.go')
| -rw-r--r-- | init.go | 37 |
1 files changed, 37 insertions, 0 deletions
@@ -3,6 +3,10 @@ package forgepb import ( + "os" + "os/user" + "path/filepath" + "go.wit.com/lib/cobol" "go.wit.com/lib/config" "go.wit.com/lib/protobuf/gitpb" @@ -51,6 +55,39 @@ func initFromConfig(cfg *ForgeConfigs) *Forge { f.Config = cfg f.Config.loadConfig() + // always define + if config.Get("username") == "" { + usr, _ := user.Current() + config.Set("username", usr.Username) + config.Save() + } + + // always define + if config.Get("homeDir") == "" { + homeDir, _ := os.UserHomeDir() + config.Set("homeDir", homeDir) + config.Save() + } + + // always define + if config.Get("gopath") == "" { + gopath := filepath.Join(config.Get("homedir"), "go/src") + config.Set("gopath", gopath) + config.Save() + } + + // always set f.mode + switch config.Get("Mode") { + case "NORMAL": + f.mode = ForgeMode_NORMAL + case "CLEAN": + f.mode = ForgeMode_CLEAN + case "MASTER": + f.mode = ForgeMode_MASTER + default: + f.mode = ForgeMode_NEWUSER + } + // todo: play with these / determine good values based on user's machine if cobol.Int(config.Get("RillX")) == 0 { config.Set("RillX", "10") |
