summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--doNewUser.go63
-rw-r--r--doRebuild.go2
-rw-r--r--main.go46
3 files changed, 70 insertions, 41 deletions
diff --git a/doNewUser.go b/doNewUser.go
new file mode 100644
index 0000000..9095377
--- /dev/null
+++ b/doNewUser.go
@@ -0,0 +1,63 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+// An app to submit patches for the 30 GO GUI repos
+
+import (
+ "fmt"
+
+ "go.wit.com/lib/fhelp"
+ "go.wit.com/lib/gui/shell"
+ "go.wit.com/lib/protobuf/forgepb"
+ "go.wit.com/log"
+)
+
+func doNewUser() (string, error) {
+ var s string
+ var err error
+
+ if shell.Exists(me.forge.Config.ReposPB) {
+ // not a new user
+ return s, err
+ }
+
+ // very likely new user
+ pfile, _ := resources.ReadFile("resources/NEWUSER")
+ log.Info("")
+ log.Info(string(pfile))
+ s = fmt.Sprintf("Initialize forge?")
+ if fhelp.QuestionUser(s) {
+ } else {
+ me.sh.GoodExit("no? porque?")
+ }
+ if fhelp.QuestionUser("forge will not look for git repos in ~/go/src") {
+ } else {
+ me.sh.GoodExit("no? porque?")
+ }
+
+ me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
+ if me.forge.Config.Mode == forgepb.ForgeMode_NEWUSER {
+ log.Info("")
+ log.Info(" A good thing to try as a new user is to rebuild forge.")
+ log.Info(" This will attempt to download all the sources & needed tools.")
+ log.Info("")
+ log.Info(" Also, you can enable bash & zsh completion with --bash & --zsh")
+ log.Info("")
+ log.Info(" todo: make better notes here.")
+ log.Info("")
+ if fhelp.QuestionUser("test question") {
+ log.Info("question true")
+ } else {
+ log.Info("question false")
+ }
+ me.forge.Config.Mode = forgepb.ForgeMode_MASTER
+ err := me.forge.ConfigSave()
+ if err != nil {
+ log.Info("ConfigSave() failed", err)
+ }
+ }
+ me.sh.GoodExit("try running: 'forge rebuild forge' to test out that forge is working on your machine")
+ return s, err
+}
diff --git a/doRebuild.go b/doRebuild.go
index 0192cd7..1bb94c3 100644
--- a/doRebuild.go
+++ b/doRebuild.go
@@ -100,7 +100,7 @@ func doRebuildForge() (string, error) {
return "forge is new. this may not work yet", errors.New("forge init not working yet")
}
repo := me.forge.Repos.FindByNamespace("go.wit.com/apps/forge")
- if repo != nil {
+ if repo == nil {
r := shell.Run([]string{"forge", "show"})
return "failed the first go around. run it again. this feature is new", r.Error
}
diff --git a/main.go b/main.go
index 65f5473..9baff99 100644
--- a/main.go
+++ b/main.go
@@ -7,9 +7,7 @@ package main
import (
"embed"
- "fmt"
- "go.wit.com/lib/fhelp"
"go.wit.com/lib/gui/prep"
"go.wit.com/lib/gui/shell"
"go.wit.com/lib/protobuf/forgepb"
@@ -30,6 +28,8 @@ var ARGNAME string = "forge"
func main() {
me = new(mainType)
+ var s string
+ var err error
// autocomplete must run before everythingi
// any writes before this to STDOUT or STDERR
@@ -39,43 +39,11 @@ func main() {
// the current forge init process
me.forge = forgepb.Init() // init forge.pb
- if !shell.Exists(me.forge.Config.ReposPB) {
- // very likely new user
- pfile, _ := resources.ReadFile("resources/NEWUSER")
- log.Info("")
- log.Info(string(pfile))
- s := fmt.Sprintf("Initialize forge?")
- if fhelp.QuestionUser(s) {
- } else {
- me.sh.GoodExit("no? porque?")
- }
- if fhelp.QuestionUser("forge will not look for git repos in ~/go/src") {
- } else {
- me.sh.GoodExit("no? porque?")
- }
- }
+ // checks if this is a new forge setup.
+ // if so, forge needs to configure things first
+ s, err = doNewUser()
+
me.forge.ScanRepoDir() // looks for new dirs, checks existing repos for changes
- if me.forge.Config.Mode == forgepb.ForgeMode_NEWUSER {
- log.Info("")
- log.Info(" A good thing to try as a new user is to rebuild forge.")
- log.Info(" This will attempt to download all the sources & needed tools.")
- log.Info("")
- log.Info(" Also, you can enable bash & zsh completion with --bash & --zsh")
- log.Info("")
- log.Info(" todo: make better notes here.")
- log.Info("")
- if fhelp.QuestionUser("test question") {
- log.Info("question true")
- } else {
- log.Info("question false")
- }
- me.forge.Config.Mode = forgepb.ForgeMode_MASTER
- err := me.forge.ConfigSave()
- if err != nil {
- log.Info("ConfigSave() failed", err)
- }
- me.sh.GoodExit("try: forge --forge-rebuild")
- }
if me.forge.Config.Mode != forgepb.ForgeMode_NORMAL {
me.forge.Config.DumpPB()
@@ -101,8 +69,6 @@ func main() {
log.Info("Starting forge with subcommand:", me.sh.Cmd)
//// start standard argv subcommand processing here ////
- var s string
- var err error
if argv.Dev != nil {
// first find the repos or gopaths to operate on
if argv.Dev.Config != nil {