Is the user new?
This commit is contained in:
parent
8202a75eea
commit
dbb0d9867d
40
init.go
40
init.go
|
@ -81,6 +81,23 @@ func Init() *Forge {
|
||||||
return f
|
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() {
|
func (f *Forge) InitPB() {
|
||||||
f.setenv()
|
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 {
|
func (f *Forge) GetForgeURL() string {
|
||||||
return f.forgeURL
|
return f.forgeURL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue