From 77c1b9258f5de5ec0e8a5d3b69c1f3cf7143c154 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Mon, 15 Jan 2024 12:43:08 -0600 Subject: [PATCH] attempt to rebuild autotypist Signed-off-by: Jeff Carr --- Makefile | 9 +++++---- main.go | 27 ++++++++++++++++++++++----- scan.go | 2 +- structs.go | 3 ++- unix.go | 30 +++++++++++++++++++++++++++++- 5 files changed, 59 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 6d0f60e..2cd0f54 100644 --- a/Makefile +++ b/Makefile @@ -1,12 +1,13 @@ -all: +all: build + myrepos + # ./myrepos >/tmp/myrepos.stderr 2>&1 + +build: echo "build it!" -mkdir -p plugins/ -cp myrepolist plugins/ -cp ~/go/src/go.wit.com/gui/toolkits/*.so plugins/ go install -v -x - # go build -v -x - myrepos - # ./myrepos >/tmp/myrepos.stderr 2>&1 redomod: rm -f go.* diff --git a/main.go b/main.go index 4d8de8e..4c682f6 100644 --- a/main.go +++ b/main.go @@ -9,7 +9,7 @@ import ( "go.wit.com/gui/gui" "go.wit.com/gui/gadgets" - "go.wit.com/gui/gadgets/repostatus" + "go.wit.com/gui/tools/repostatus" ) //go:embed plugins/* @@ -93,7 +93,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri // This creates a window func repoworld() { - reposwin = gadgets.NewBasicWindow(myGui, "git autotypist. it types faster than you can.") + reposwin = gadgets.NewBasicWindow(myGui, "autotypist for GO & git. it types faster than you can.") reposwin.Make() reposbox = reposwin.Box().NewBox("bw vbox", false) @@ -178,9 +178,17 @@ func repoworld() { buildOptions.NewLabel("get autotypist") buildOptions.NewButton("go get", func () { var newCmds [][]string - newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/myrepos"}) - newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/myrepos"}) - newCmds = append(newCmds, []string{"go", "git", "-v", "-u"}) + newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/apps"}) + newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"}) + newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "go.wit.com/apps/myrepos"}) + newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"}) + newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."}) + newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "go.wit.com/gui/toolkits"}) + newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits"}) + newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."}) + newCmds = append(newCmds, []string{"go", "make"}) + newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"}) + newCmds = append(newCmds, []string{"go", "make"}) script = newCmds setGitCommands() doit.Enable() @@ -200,6 +208,15 @@ func repoworld() { buildOptions.NewLabel("cmd") cmds = buildOptions.NewLabel("ls") + buildOptions.NewLabel("--dry-run") + dryrun = buildOptions.NewButton("show commands", func () { + if dryRunCommands() { + log.Warn("EVERYTHING MIGHT HAVE WORKED") + } else { + log.Warn("EVERYTHING DID NOT WORK") + } + }) + buildOptions.NewLabel("Doit") doit = buildOptions.NewButton("run commands", func () { doit.Disable() diff --git a/scan.go b/scan.go index b10af4f..d31633c 100644 --- a/scan.go +++ b/scan.go @@ -4,7 +4,7 @@ package main import ( "go.wit.com/log" - "go.wit.com/gui/gadgets/repostatus" + "go.wit.com/gui/tools/repostatus" ) func (r *repo) newScan() bool { diff --git a/structs.go b/structs.go index 39990c8..d4dcc82 100644 --- a/structs.go +++ b/structs.go @@ -4,7 +4,7 @@ package main import ( "go.wit.com/gui/gui" "go.wit.com/gui/gadgets" - "go.wit.com/gui/gadgets/repostatus" + "go.wit.com/gui/tools/repostatus" ) // the main window nodes @@ -16,6 +16,7 @@ var reposgroup *gui.Node var cmds *gui.Node var script [][]string var doit *gui.Node +var dryrun *gui.Node var allrepos []*repo diff --git a/unix.go b/unix.go index adb0b95..d167636 100644 --- a/unix.go +++ b/unix.go @@ -4,11 +4,39 @@ import ( "strings" "go.wit.com/log" - "go.wit.com/gui/gadgets/repostatus" + "go.wit.com/gui/tools/repostatus" ) var repopath string = "/home/jcarr/" +func dryRunCommands() bool { + var workingPath string = "go/src" + for _, line := range script { + if len(line) == 0 { + continue + } + if line[0] == "cd" { + switch len(line) { + case 1: + log.Verbose("do cmdPwd() to go root", repopath + "go/src") + workingPath = "" + case 2: + log.Verbose("do cmdPwd() here", line) + workingPath = line[1] + default: + log.Warn("bad cd", line) + return false + } + continue + } + cmd := line[0] + s := strings.Join(line[1:], " ") + path := repopath + workingPath + log.Warn("NEED TO RUN path =", path, "cmd =", cmd, "argv:", s) + } + return true +} + func runCommands() bool { for _, line := range script { s := strings.Join(line, " ")