From 2daf0189f628f7214cdc9295f898c355636ef9a3 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 15 Oct 2025 17:44:34 -0500 Subject: better name & bash autocomplete works --- argv.go | 12 ++++-- doDownloadForge.go | 101 ------------------------------------------------ doRebuild.go | 111 +++++++++++++++++++++++++++++++++++++++++++++++++++++ main.go | 4 +- windowHowto.go | 2 +- 5 files changed, 123 insertions(+), 107 deletions(-) delete mode 100644 doDownloadForge.go create mode 100644 doRebuild.go diff --git a/argv.go b/argv.go index 3f15f7d..770bfa6 100644 --- a/argv.go +++ b/argv.go @@ -34,11 +34,11 @@ type args struct { Fixer *FixCmd `arg:"subcommand:fixer" help:"send in the fixer"` Verify *VerifyCmd `arg:"subcommand:verify" help:"populate stats"` Whatchanged *EmptyCmd `arg:"subcommand:whatchanged" help:"being deprecated (perhaps?). this is just for finger memory."` + Rebuild *RebuildCmd `arg:"subcommand:rebuild" help:"download all the forge sources and rebuild forge"` All bool `arg:"--all" help:"whatever you are doing, do it all over"` Force bool `arg:"--force" help:"try to strong-arm things"` Verbose bool `arg:"--verbose" help:"show more output than usual"` Fix bool `arg:"--fix" help:"try to make repairs"` - BuildForge bool `arg:"--forge-rebuild" help:"download all the forge sources and rebuild forge"` } type EmptyCmd struct { @@ -55,6 +55,12 @@ type ShowCmd struct { Tag *TagCmd `arg:"subcommand:tag" help:"show git tags"` } +type RebuildCmd struct { + Forge *EmptyCmd `arg:"subcommand:forge" help:"rebuild forge"` + GoClone *EmptyCmd `arg:"subcommand:go-clone" help:"rebuild go-clone"` + Autogenpb *EmptyCmd `arg:"subcommand:autogenpb" help:"rebuild autogenpb"` +} + type FixCmd struct { Porcelain *EmptyCmd `arg:"subcommand:porcelain" help:"git status --porcelain"` Urls bool `arg:"--urls" help:"check for changes in repo urls"` @@ -237,9 +243,9 @@ func (args) Examples() string { func (a args) SendCompletionStrings(pb *prep.Auto) { if pb.Cmd == "" { // these are base autocomplete strings - matches := []string{"checkout", "clean", "commit", "merge", "patch", "normal", "pull"} + matches := []string{"checkout", "clean", "commit", "merge", "patch", "normal", "pull", "rebuild"} matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui", "whatchanged") - matches = append(matches, "--version", "--force", "--all", "--forge-rebuild") + matches = append(matches, "--version", "--force", "--all") pb.SendStrings(matches) } else { // autogenerate the strings for the subcommand using github.com/alexflint/go-arg diff --git a/doDownloadForge.go b/doDownloadForge.go deleted file mode 100644 index f690370..0000000 --- a/doDownloadForge.go +++ /dev/null @@ -1,101 +0,0 @@ -// 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 ( - "errors" - "os" - - "go.wit.com/lib/fhelp" - "go.wit.com/lib/gui/shell" - "go.wit.com/log" -) - -// download forge. A good way to check things work -func doDownloadForge() (string, error) { - log.Info("download here") - if path, err := fhelp.CheckCmd("go-clone"); err != nil { - log.Info("go-clone missing", path, err) - cmd := []string{"go", "install", "go.wit.com/apps/go-clone@latest"} - shell.RunRealtime(cmd) - } - if _, err := fhelp.CheckCmd("autogenpb"); err != nil { - cmd := []string{"go", "install", "go.wit.com/apps/autogenpb@latest"} - shell.RunRealtime(cmd) - } - if _, err := fhelp.CheckCmd("go-mod-clean"); err != nil { - cmd := []string{"go", "install", "go.wit.com/apps/go-mod-clean@latest"} - shell.RunRealtime(cmd) - } - if path, err := fhelp.CheckCmd("go-clone"); err != nil { - log.Info("can't prep build. you probably need ~/go/bin in your PATH", path, err) - return "", errors.New("prep build failed") - } - var basecmd []string - var cmd []string - if me.forge.IsGoWork() { - log.Info("Using go.work directory") - basecmd = []string{"go-clone", "--work"} - } else { - basecmd = []string{"go-clone"} - } - // log.Info("Running:", cmd) - // shell.RunRealtime(cmd) - - r := shell.Run([]string{"forge", "show"}) - if r.Error != nil { - return "download go-mod-clean failed", r.Error - } - - cmd = append(basecmd, "go.wit.com/apps/go-mod-clean") - log.Info("Running:", cmd) - r = shell.RunRealtime(cmd) - if r.Error != nil { - return "download go-mod-clean failed", r.Error - } - - cmd = append(basecmd, "go.wit.com/apps/autogenpb") - log.Info("Running:", cmd) - r = shell.RunRealtime(cmd) - if r.Error != nil { - return "download autogenpb failed", r.Error - } - - cmd = append(basecmd, "go.wit.com/apps/forge") - log.Info("Running:", cmd) - r = shell.RunRealtime(cmd) - if r.Error != nil { - me.sh.BadExit("download forge failed", r.Error) - } - - cmd = append(basecmd, "go.wit.com/toolkits/gocui") - log.Info("Running:", cmd) - r = shell.RunRealtime(cmd) - if r.Error != nil { - me.sh.BadExit("download CUI GO plugin toolkit failed", r.Error) - } - - cmd = append(basecmd, "go.wit.com/toolkits/andlabs") - log.Info("Running:", cmd) - r = shell.RunRealtime(cmd) - if r.Error != nil { - me.sh.BadExit("download GTK GO plugin toolkit failed", r.Error) - } - - if (me.forge == nil) || (me.forge.Repos == nil) { - log.Info("RUN forge --rebuild again. it might work after a few tries") - 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 { - r := shell.Run([]string{"forge", "show"}) - return "failed the first go around. run it again. this feature is new", r.Error - } - // yay. it might work - os.Chdir(repo.FullPath) - r = shell.Run([]string{"make", "generate"}) - return "make generate might have worked", r.Error -} diff --git a/doRebuild.go b/doRebuild.go new file mode 100644 index 0000000..0192cd7 --- /dev/null +++ b/doRebuild.go @@ -0,0 +1,111 @@ +// 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 ( + "errors" + "os" + + "go.wit.com/lib/fhelp" + "go.wit.com/lib/gui/shell" + "go.wit.com/log" +) + +// download forge. A good way to check things work +func doRebuild() (string, error) { + var s string + var err error + + if argv.Rebuild.Forge != nil { + s, err = doRebuildForge() + } + return s, err +} + +func doRebuildForge() (string, error) { + log.Info("download here") + if path, err := fhelp.CheckCmd("go-clone"); err != nil { + log.Info("go-clone missing", path, err) + cmd := []string{"go", "install", "go.wit.com/apps/go-clone@latest"} + shell.RunRealtime(cmd) + } + if _, err := fhelp.CheckCmd("autogenpb"); err != nil { + cmd := []string{"go", "install", "go.wit.com/apps/autogenpb@latest"} + shell.RunRealtime(cmd) + } + if _, err := fhelp.CheckCmd("go-mod-clean"); err != nil { + cmd := []string{"go", "install", "go.wit.com/apps/go-mod-clean@latest"} + shell.RunRealtime(cmd) + } + if path, err := fhelp.CheckCmd("go-clone"); err != nil { + log.Info("can't prep build. you probably need ~/go/bin in your PATH", path, err) + return "", errors.New("prep build failed") + } + var basecmd []string + var cmd []string + if me.forge.IsGoWork() { + log.Info("Using go.work directory") + basecmd = []string{"go-clone", "--work"} + } else { + basecmd = []string{"go-clone"} + } + // log.Info("Running:", cmd) + // shell.RunRealtime(cmd) + + r := shell.Run([]string{"forge", "show"}) + if r.Error != nil { + return "download go-mod-clean failed", r.Error + } + + cmd = append(basecmd, "go.wit.com/apps/go-mod-clean") + log.Info("Running:", cmd) + r = shell.RunRealtime(cmd) + if r.Error != nil { + return "download go-mod-clean failed", r.Error + } + + cmd = append(basecmd, "go.wit.com/apps/autogenpb") + log.Info("Running:", cmd) + r = shell.RunRealtime(cmd) + if r.Error != nil { + return "download autogenpb failed", r.Error + } + + cmd = append(basecmd, "go.wit.com/apps/forge") + log.Info("Running:", cmd) + r = shell.RunRealtime(cmd) + if r.Error != nil { + me.sh.BadExit("download forge failed", r.Error) + } + + cmd = append(basecmd, "go.wit.com/toolkits/gocui") + log.Info("Running:", cmd) + r = shell.RunRealtime(cmd) + if r.Error != nil { + me.sh.BadExit("download CUI GO plugin toolkit failed", r.Error) + } + + cmd = append(basecmd, "go.wit.com/toolkits/andlabs") + log.Info("Running:", cmd) + r = shell.RunRealtime(cmd) + if r.Error != nil { + me.sh.BadExit("download GTK GO plugin toolkit failed", r.Error) + } + + if (me.forge == nil) || (me.forge.Repos == nil) { + log.Info("RUN forge --rebuild again. it might work after a few tries") + 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 { + r := shell.Run([]string{"forge", "show"}) + return "failed the first go around. run it again. this feature is new", r.Error + } + // yay. it might work + os.Chdir(repo.FullPath) + r = shell.Run([]string{"make", "generate"}) + return "make generate might have worked", r.Error +} diff --git a/main.go b/main.go index 9c266ef..65f5473 100644 --- a/main.go +++ b/main.go @@ -173,10 +173,10 @@ func main() { err = r.Error } - if argv.BuildForge { + if argv.Rebuild != nil { // attempts to download all the sources // and binaries needed to build forge - s, err = doDownloadForge() + s, err = doRebuild() } if argv.Verify != nil { diff --git a/windowHowto.go b/windowHowto.go index f626af3..a556449 100644 --- a/windowHowto.go +++ b/windowHowto.go @@ -42,7 +42,7 @@ func makeHowtoWin() *gadgets.GenericWindow { grid.NewButton("Download into "+me.forge.Config.ReposDir, func() { howtoWin.Disable() defer howtoWin.Enable() - doDownloadForge() + doRebuildForge() }) return howtoWin } -- cgit v1.2.3