From dbb0d9867d645c4082e910098fa84dc15299c454 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Thu, 4 Sep 2025 20:02:38 -0500 Subject: [PATCH] Is the user new? --- init.go | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) 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 }