summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-21 04:49:06 -0500
committerJeff Carr <[email protected]>2025-10-21 04:49:06 -0500
commitc9fae2681ba33612fca2418523964cfc7b92cac1 (patch)
tree471ed9830399c5f36210f3ceff6c0b90c41d42bd /init.go
parent69b5038c58e6a8487f22aeaf28eddec5c785c283 (diff)
starting to limp back to working
Diffstat (limited to 'init.go')
-rw-r--r--init.go37
1 files changed, 37 insertions, 0 deletions
diff --git a/init.go b/init.go
index ce7d8eb..695319d 100644
--- a/init.go
+++ b/init.go
@@ -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")