summaryrefslogtreecommitdiff
path: root/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'init.go')
-rw-r--r--init.go49
1 files changed, 49 insertions, 0 deletions
diff --git a/init.go b/init.go
index 57e18fd..72100df 100644
--- a/init.go
+++ b/init.go
@@ -180,3 +180,52 @@ func (f *Forge) Exit() {
// log.Info("forge.Exit() ok")
os.Exit(0)
}
+
+func RawInitPB() *Forge {
+ f := new(Forge)
+
+ homeDir, _ := os.UserHomeDir()
+ // todo: check or exit if err?
+
+ // TODO: rethink this but it works for now
+ if os.Getenv("FORGE_GOSRC") == "" {
+ fullpath := filepath.Join(homeDir, ".cache/forge")
+ err := os.MkdirAll(fullpath, os.ModePerm)
+ if err != nil {
+ log.Log(WARN, "mkdir failed", fullpath, err)
+ }
+ os.Setenv("FORGE_GOSRC", fullpath)
+ }
+ f.goSrc = os.Getenv("FORGE_GOSRC")
+
+ // also rethink this, but maybe this is the right thing to do
+ if os.Getenv("FORGE_CONFIG") == "" {
+ fullpath := filepath.Join(homeDir, ".config/forge")
+ os.MkdirAll(fullpath, os.ModePerm)
+ os.Setenv("FORGE_CONFIG", fullpath)
+ }
+
+ f.configDir = os.Getenv("FORGE_CONFIG")
+
+ // load the ~/.config/forge/ config
+ f.Config = new(ForgeConfigs)
+ if err := f.Config.ConfigLoad(); err != nil {
+ log.Log(WARN, "forgepb.ConfigLoad() failed", err)
+ }
+
+ f.Repos = gitpb.NewRepos()
+ f.Repos.ConfigLoad()
+
+ f.forgeURL = "https://forge.wit.com/"
+
+ if os.Getenv("FORGE_URL") != "" {
+ f.forgeURL = os.Getenv("FORGE_URL")
+ log.Info("got forge url", f.forgeURL)
+ }
+
+ // todo: play with these / determine good values based on user's machine
+ f.rillX = 10
+ f.rillY = 20
+
+ return f
+}