summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.go40
1 files changed, 40 insertions, 0 deletions
diff --git a/init.go b/init.go
index 93104ee..9f72a92 100644
--- a/init.go
+++ b/init.go
@@ -81,6 +81,23 @@ func Init() *Forge {
return f
}
+func FirstTimeUser() bool {
+ if checkenv() {
+ return true
+ }
+
+ // setup the env
+ f := new(Forge)
+ f.setenv()
+
+ f.Config = new(ForgeConfigs)
+ if err := f.Config.ConfigLoad(f.configDir); err != nil {
+ // no config
+ return true
+ }
+ return false
+}
+
func (f *Forge) InitPB() {
f.setenv()
@@ -165,6 +182,29 @@ func (f *Forge) setenv() {
})
}
+// if the env vars are set, this is probably not a new user
+func checkenv() bool {
+ if os.Getenv("FORGE_CONFIG") != "" {
+ return true
+ }
+ if os.Getenv("FORGE_GOSRC") != "" {
+ return true
+ }
+ if os.Getenv("FORGE_REPOPB") != "" {
+ return true
+ }
+ if os.Getenv("FORGE_URL") != "" {
+ return true
+ }
+ if os.Getenv("FORGE_PATCHDIR") != "" {
+ return true
+ }
+ if os.Getenv("FORGE_VERBOSE") != "" {
+ return true
+ }
+ return false
+}
+
func (f *Forge) GetForgeURL() string {
return f.forgeURL
}