From d44985fea3b5a789c7e3b73f152b0c7eb3e9f4fe Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Tue, 28 Oct 2025 09:14:12 -0500 Subject: this needs to be redone --- init.go | 20 +++----------------- mode.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/init.go b/init.go index d5dfb79..6962c67 100644 --- a/init.go +++ b/init.go @@ -119,23 +119,9 @@ func (f *Forge) postInit() error { env.SetGlobal("lib/forgepb", "curpatches", "curpatches.pb") } - // always set f.mode - switch env.Get("Mode") { - case "NORMAL": - f.mode = ForgeMode_NORMAL - case "CUSTOM": - f.mode = ForgeMode_CUSTOM - case "GOLANG": - f.mode = ForgeMode_GOLANG - case "CLEAN": - f.mode = ForgeMode_CLEAN - case "MASTER": - f.mode = ForgeMode_MASTER - case "DEVEL": - f.mode = ForgeMode_DEVEL - default: - f.mode = ForgeMode_NEWUSER - } + // converts the lib/ENV "mode" string + // todo: rethink all this + f.mode = getModeENV() // todo: play with these / determine good values based on user's machine if cobol.Int(env.Get("RillX")) == 0 { diff --git a/mode.go b/mode.go index 21976fb..3711f9a 100644 --- a/mode.go +++ b/mode.go @@ -2,6 +2,12 @@ package forgepb +import ( + "fmt" + + "go.wit.com/lib/env" +) + // TODO: implement i18n with the protobuf's func (f *Forge) GetMode() string { switch f.mode { @@ -16,6 +22,31 @@ func (f *Forge) GetMode() string { } } +func getModeENV() ForgeMode { + // always set f.mode // todo: do something else besides this ? + switch env.Get("Mode") { + case "NORMAL": + return ForgeMode_NORMAL + case "CUSTOM": + return ForgeMode_CUSTOM + case "GOLANG": + return ForgeMode_GOLANG + case "CLEAN": + return ForgeMode_CLEAN + case "MASTER": + return ForgeMode_MASTER + case "DEVEL": + return ForgeMode_DEVEL + case "USER": + return ForgeMode_USER + case "NEWUSER": + return ForgeMode_NEWUSER + default: + fmt.Printf("MODE ERROR (%s)\n", env.Get("Mode")) + } + return ForgeMode_NEWUSER +} + // indicates the user is trying to cleanup repos // stays in this mode until the user leaves it // should not change the repos selected -- cgit v1.2.3