command line option to rebuild

This commit is contained in:
Jeff Carr 2025-02-22 09:42:49 -06:00
parent ec11efc347
commit 1d4817f6af
3 changed files with 83 additions and 88 deletions

37
argv.go
View File

@ -15,24 +15,25 @@ import (
var argv args
type args struct {
Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch branches using 'git checkout'"`
Clean *CleanCmd `arg:"subcommand:clean" help:"start over at the beginning"`
Commit *EmptyCmd `arg:"subcommand:commit" help:"'git commit' but errors out if on wrong branch"`
Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"`
Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show repos git says are dirty"`
GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"`
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"`
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
URL string `arg:"--connect" help:"forge url"`
All bool `arg:"--all" help:"git commit --all"`
Show string `arg:"--show" help:"show a repo"`
Build string `arg:"--build" help:"build a repo"`
Install string `arg:"--install" help:"install a repo"`
Force bool `arg:"--force" help:"try to strong arm things"`
Verbose bool `arg:"--verbose" help:"show more output"`
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
Checkout *CheckoutCmd `arg:"subcommand:checkout" help:"switch branches using 'git checkout'"`
Clean *CleanCmd `arg:"subcommand:clean" help:"start over at the beginning"`
Commit *EmptyCmd `arg:"subcommand:commit" help:"'git commit' but errors out if on wrong branch"`
Config *ConfigCmd `arg:"subcommand:config" help:"show your .config/forge/ settings"`
Dirty *DirtyCmd `arg:"subcommand:dirty" help:"show repos git says are dirty"`
GitFetch *FindCmd `arg:"subcommand:fetch" help:"run 'git fetch master'"`
List *FindCmd `arg:"subcommand:list" help:"print a table of the current repos"`
Patch *PatchCmd `arg:"subcommand:patch" help:"make patchsets"`
GitPull *FindCmd `arg:"subcommand:pull" help:"run 'git pull'"`
URL string `arg:"--connect" help:"forge url"`
All bool `arg:"--all" help:"git commit --all"`
Build string `arg:"--build" help:"build a repo"`
Install string `arg:"--install" help:"install a repo"`
BuildForge bool `arg:"--forge-rebuild" help:"download and rebuild forge"`
Force bool `arg:"--force" help:"try to strong arm things"`
Verbose bool `arg:"--verbose" help:"show more output"`
Bash bool `arg:"--bash" help:"generate bash completion"`
BashAuto []string `arg:"--auto-complete" help:"todo: move this to go-arg"`
// Show string `arg:"--show" help:"show a repo"`
}
type EmptyCmd struct {

22
main.go
View File

@ -79,6 +79,11 @@ func main() {
okExit("")
}
if argv.BuildForge {
buildForge()
okExit("")
}
if argv.Checkout != nil {
if err := doCheckout(); err != nil {
badExit(err)
@ -124,23 +129,6 @@ func main() {
okExit("")
}
if argv.Show != "" {
repo := me.forge.FindByGoPath(argv.Show)
me.forge.HumanPrintRepo(repo)
// newt := repo.Times.LastUpdate.AsTime()
// oldt := repo.Times.MtimeHead.AsTime()
if repo.Times.LastUpdate == nil {
log.Info("SHOULD RUN Reload() here")
repo.Reload()
me.forge.HumanPrintRepo(repo)
} else {
if repo.Times.LastUpdate.Seconds < repo.Times.MtimeHead.Seconds {
log.Info("SHOULD RUN Reload() here")
}
}
okExit("")
}
if argv.GitFetch != nil {
doGitFetch()
okExit("")

View File

@ -6,6 +6,8 @@ package main
// An app to submit patches for the 30 GO GUI repos
import (
"os"
"go.wit.com/lib/fhelp"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
@ -43,59 +45,63 @@ func makeHowtoWin() *genericWindow {
grid.NewButton("Download", func() {
howtoWin.Disable()
defer howtoWin.Enable()
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
}
var basecmd []string
var cmd []string
if me.forge.IsGoWork() {
log.Info("NOT GO WORK")
basecmd = []string{"go-clone", "--work", "--recursive"}
} else {
log.Info("IS GO WORK")
basecmd = []string{"go-clone", "--recursive"}
}
// log.Info("Running:", cmd)
// shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/apps/go-mod-clean")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/apps/forge")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/toolkits/gocui")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/toolkits/andlabs")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
// 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"})
}
*/
buildForge()
})
return howtoWin
}
func buildForge() {
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
}
var basecmd []string
var cmd []string
if me.forge.IsGoWork() {
log.Info("Using go.work directory")
basecmd = []string{"go-clone", "--work", "--recursive"}
} else {
basecmd = []string{"go-clone", "--recursive"}
}
// log.Info("Running:", cmd)
// shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/apps/go-mod-clean")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
os.Exit(-1)
cmd = append(basecmd, "go.wit.com/apps/forge")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/toolkits/gocui")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
cmd = append(basecmd, "go.wit.com/toolkits/andlabs")
log.Info("Running:", cmd)
shell.RunRealtime(cmd)
// 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"})
}
*/
}