summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-28 09:14:12 -0500
committerJeff Carr <[email protected]>2025-10-28 09:14:12 -0500
commitd44985fea3b5a789c7e3b73f152b0c7eb3e9f4fe (patch)
tree078cd1dccca34f785df4dca0ab4e503ee8f192f7
parentc5a92b421f202a5b8c807d618aa6edf1cb7db325 (diff)
this needs to be redone
-rw-r--r--init.go20
-rw-r--r--mode.go31
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