diff options
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") |
