From c7ea7e0a0be0164c5d6b2fa33bb0fc050e1c20c3 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Wed, 15 Oct 2025 09:41:07 -0500 Subject: attempt again --- argv.go | 50 +++++++++++++++++++++++++------------------------- doDev.go | 5 ----- doDownloadForge.go | 33 +++++++++++++++++++++------------ main.go | 5 +++++ 4 files changed, 51 insertions(+), 42 deletions(-) diff --git a/argv.go b/argv.go index 67dfcef..0a70d1c 100644 --- a/argv.go +++ b/argv.go @@ -19,24 +19,25 @@ import ( var argv args type args struct { - Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"'git checkout'"` - Clean *CleanCmd `arg:"subcommand:clean" help:"'git clean' + reset repos to original state"` - Commit *CommitCmd `arg:"subcommand:commit" help:"'git commit'"` - Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` - Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` - Normal *ModeCmd `arg:"subcommand:normal" help:"shortcut to 'forge mode normal'"` - Mode *ModeCmd `arg:"subcommand:mode" help:"sets the mode (hacking, merging, publishing)"` - Patch *PatchCmd `arg:"subcommand:patch" help:"work with patchsets"` - Pull *PullCmd `arg:"subcommand:pull" help:"'git pull'"` - Show *ShowCmd `arg:"subcommand:show" help:"print out things"` - Dev *DevCmd `arg:"subcommand:dev" help:"features under development"` - Add *EmptyCmd `arg:"subcommand:add" help:"Scan directores for git repos"` - Fixer *FixCmd `arg:"subcommand:fixer" help:"send in the fixer"` - Verify *VerifyCmd `arg:"subcommand:verify" help:"populate stats"` - 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"` + Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"'git checkout'"` + Clean *CleanCmd `arg:"subcommand:clean" help:"'git clean' + reset repos to original state"` + Commit *CommitCmd `arg:"subcommand:commit" help:"'git commit'"` + Gui *EmptyCmd `arg:"subcommand:gui" help:"open the gui"` + Merge *MergeCmd `arg:"subcommand:merge" help:"merge branches"` + Normal *ModeCmd `arg:"subcommand:normal" help:"shortcut to 'forge mode normal'"` + Mode *ModeCmd `arg:"subcommand:mode" help:"sets the mode (hacking, merging, publishing)"` + Patch *PatchCmd `arg:"subcommand:patch" help:"work with patchsets"` + Pull *PullCmd `arg:"subcommand:pull" help:"'git pull'"` + Show *ShowCmd `arg:"subcommand:show" help:"print out things"` + Dev *DevCmd `arg:"subcommand:dev" help:"features under development"` + Add *EmptyCmd `arg:"subcommand:add" help:"Scan directores for git repos"` + Fixer *FixCmd `arg:"subcommand:fixer" help:"send in the fixer"` + Verify *VerifyCmd `arg:"subcommand:verify" help:"populate stats"` + 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 { @@ -92,12 +93,11 @@ type CommitCmd struct { } type DevCmd struct { - Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"` - Build *EmptyCmd `arg:"subcommand:build" help:"build this repo"` - Install *EmptyCmd `arg:"subcommand:install" help:"build & install this repo"` - Generate string `arg:"--generate" help:"run go generate"` - BuildForge bool `arg:"--forge-rebuild" help:"download all the forge sources and rebuild forge"` - URL string `arg:"--connect" help:"forge url"` + Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"` + Build *EmptyCmd `arg:"subcommand:build" help:"build this repo"` + Install *EmptyCmd `arg:"subcommand:install" help:"build & install this repo"` + Generate string `arg:"--generate" help:"run go generate"` + URL string `arg:"--connect" help:"forge url"` } type CleanCmd struct { @@ -238,7 +238,7 @@ func (a args) SendCompletionStrings(pb *prep.Auto) { // these are base autocomplete strings matches := []string{"checkout", "clean", "commit", "merge", "patch", "normal", "pull"} matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui") - matches = append(matches, "--version", "--force", "--all") + matches = append(matches, "--version", "--force", "--all", "--forge-rebuild") pb.SendStrings(matches) } else { // autogenerate the strings for the subcommand using github.com/alexflint/go-arg diff --git a/doDev.go b/doDev.go index 07df3c0..b68cf39 100644 --- a/doDev.go +++ b/doDev.go @@ -56,10 +56,5 @@ func doDev() (string, error) { } return "build ok", nil } - - if argv.Dev.BuildForge { - doDownloadForge() - return "todo: build forge", nil - } return "todo: do something here", nil } diff --git a/doDownloadForge.go b/doDownloadForge.go index 5d86218..f690370 100644 --- a/doDownloadForge.go +++ b/doDownloadForge.go @@ -6,13 +6,16 @@ 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() { +func doDownloadForge() (string, error) { log.Info("download here") if path, err := fhelp.CheckCmd("go-clone"); err != nil { log.Info("go-clone missing", path, err) @@ -29,7 +32,7 @@ func doDownloadForge() { } 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 + return "", errors.New("prep build failed") } var basecmd []string var cmd []string @@ -44,21 +47,21 @@ func doDownloadForge() { r := shell.Run([]string{"forge", "show"}) if r.Error != nil { - me.sh.BadExit("download go-mod-clean failed", r.Error) + 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 { - me.sh.BadExit("download go-mod-clean failed", r.Error) + 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 { - me.sh.BadExit("download autogenpb failed", r.Error) + return "download autogenpb failed", r.Error } cmd = append(basecmd, "go.wit.com/apps/forge") @@ -82,11 +85,17 @@ func doDownloadForge() { me.sh.BadExit("download GTK GO plugin toolkit failed", r.Error) } - // should, after go-clone, be able to go build - /* - repo := me.forge.FindByGoPath("go.wit.com/lib/proto/forgepb") - if repo != nil { - repo.RunVerbose([]string{"autogenpb"}) - } - */ + 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 6154705..9f88b9b 100644 --- a/main.go +++ b/main.go @@ -121,6 +121,11 @@ func main() { if argv.Patch != nil { s, err = doPatch() } + if argv.BuildForge { + // attempts to download all the sources + // and binaries needed to build forge + s, err = doDownloadForge() + } if argv.Verify != nil { s, err = doVerify() -- cgit v1.2.3