Is the user new?

This commit is contained in:
Jeff Carr 2025-09-04 20:02:38 -05:00
parent 8202a75eea
commit dbb0d9867d
1 changed files with 40 additions and 0 deletions

40
init.go
View File

@ -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
}