summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--globalBuildOptions.go121
-rw-r--r--main.go200
-rw-r--r--resetOptions.go124
-rw-r--r--structs.go13
-rw-r--r--unix.go35
5 files changed, 276 insertions, 217 deletions
diff --git a/globalBuildOptions.go b/globalBuildOptions.go
new file mode 100644
index 0000000..b8bf594
--- /dev/null
+++ b/globalBuildOptions.go
@@ -0,0 +1,121 @@
+// This is a simple example
+package main
+
+import (
+ "os"
+ "strings"
+
+ "go.wit.com/log"
+
+ "go.wit.com/gui/gui"
+ "go.wit.com/gui/gadgets"
+)
+
+func doesExist(path string) bool {
+ if _, err := os.Stat(path); err != nil {
+ if os.IsNotExist(err) {
+ return false
+ }
+ }
+ return true
+}
+
+func globalBuildOptions(box *gui.Node) {
+ var setCurrentBranch *gui.Node
+ group1 := box.NewGroup("Global Build Options")
+ groupvbox := group1.NewBox("bw vbox", false)
+ // grouphbox := groupvbox.NewBox("bw hbox", true)
+
+ grid := groupvbox.NewGrid("buildOptions",2, 1)
+
+ me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
+ me.mainBranch.Add("guimain")
+ me.mainBranch.Add("gitea server default")
+ me.mainBranch.Disable()
+
+ me.develBranch = gadgets.NewBasicCombobox(grid, "default devel branch")
+ me.develBranch.Add("devel")
+
+ me.userBranch = gadgets.NewBasicCombobox(grid, "default user branch")
+ me.userBranch.Add("jcarr")
+
+ // select the branch you want to test, build and develop against
+ // this lets you select your user branch, but, when you are happy
+ // you can merge everything into the devel branch and make sure it actually
+ // works. Then, when that is good, merge and version everything in master
+ guiBranch := gadgets.NewBasicCombobox(grid, "Set Current Working Branch")
+ guiBranch.Add("guimaster")
+ guiBranch.Add("guidevel")
+ guiBranch.Add("jcarr")
+ guiBranch.Custom = func () {
+ me.toMoveToBranch = guiBranch.Get()
+ setCurrentBranch.Set("set all branches to " + me.toMoveToBranch)
+ me.mainBranch.Disable()
+ }
+
+ setCurrentBranch = groupvbox.NewButton("set all branches to", func () {
+ for _, repo := range allrepos {
+ var changeBranch [][]string
+ // realname, realversion := repo.status.CheckoutBranch(me.toMoveToBranch)
+ // log.Warn("GOT", realname, realversion)
+ path := repo.status.GetPath()
+ changeBranch = append(changeBranch, []string{"cd", "go/src/" + path})
+ changeBranch = append(changeBranch, []string{"git", "checkout", me.toMoveToBranch})
+ me.script = changeBranch
+ setGitCommands()
+ goMake("--doit")
+ return
+ }
+ })
+ var everything *gui.Node
+ everything = groupvbox.NewButton("go get everything on go.wit.com", func () {
+ var perfect bool = true
+ var newCmds [][]string
+ // usr, _ := user.Current()
+ newCmds = append(newCmds, []string{"cd", "go/src/gui/app/myrepos"})
+ repos := myrepolist()
+ for _, line := range repos {
+ log.Warn("repo =", line)
+ path, _, _, _ := splitLine(line)
+ path = strings.TrimSpace(path)
+ if path == "#" {
+ // skip comment lines
+ continue
+ }
+ if doesExist("/home/jcarr/go/src/" + path) {
+ continue
+ }
+ newCmds = append(newCmds, []string{"go", "get", "-v", path})
+ perfect = false
+ }
+
+ if perfect {
+ var notes [][]string
+ notes = append(notes, []string{"you have already downloaded"})
+ notes = append(notes, []string{"everything on go.wit.com"})
+ me.script = notes
+ setGitCommands()
+ doit.Disable()
+ everything.Disable()
+ return
+ }
+
+ me.script = newCmds
+ doit.Enable()
+ setGitCommands()
+ })
+ groupvbox.NewButton("build all apps", func () {
+ })
+
+ groupvbox.NewButton("status.Update() all", func () {
+ for _, repo := range allrepos {
+ repo.status.Update()
+ }
+ })
+
+ groupvbox.NewButton("rescan all", func () {
+ for _, repo := range allrepos {
+ repo.newScan()
+ }
+ })
+}
diff --git a/main.go b/main.go
index 5cff189..9afca5d 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,6 @@
package main
import (
- "os"
"os/user"
"embed"
@@ -48,28 +47,6 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
newRepo.dirtyLabel = grid.NewLabel("")
- /*
- newRepo.pButton = grid.NewButton("rescan", func () {
- newRepo.newScan()
- })
-
- grid.NewButton("Update()", func () {
- if newRepo.status == nil {
- log.Warn("status window doesn't exist")
- return
- }
- log.Warn("status window exists. trying Update() here")
- newRepo.status.Update()
- })
- grid.NewButton("Hide()", func () {
- if newRepo.status == nil {
- log.Warn("status window doesn't exist")
- return
- }
- log.Warn("status window exists. trying Hide() here")
- newRepo.status.Hide()
- })
- */
grid.NewButton("Show()", func () {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
@@ -92,68 +69,6 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
allrepos = append(allrepos, newRepo)
}
-// just returns if something exists at the path name (file, directory, whatever)
-func doesExist(path string) bool {
- if _, err := os.Stat(path); err != nil {
- if os.IsNotExist(err) {
- return false
- }
- }
- return true
-}
-
-func globalBuildOptions(box *gui.Node) {
- var setCurrentBranch *gui.Node
- group1 := box.NewGroup("Global Build Options")
- groupvbox := group1.NewBox("bw vbox", false)
- grouphbox := groupvbox.NewBox("bw hbox", true)
- guiBranch := gadgets.NewBasicCombobox(grouphbox, "Select GUI branch")
- guiBranch.Add("guimaster")
- guiBranch.Add("guidevel")
- guiBranch.Add("jcarr")
- guiBranch.Custom = func () {
- tmp := "set all current branchs to " + guiBranch.Get()
- setCurrentBranch.Set(tmp)
- }
-
- setCurrentBranch = groupvbox.NewButton("set current branch to", func () {
- for _, repo := range allrepos {
- repo.status.Update()
- }
- })
- groupvbox.NewButton("go get everything in configfile", func () {
- var newCmds [][]string
- // usr, _ := user.Current()
- newCmds = append(newCmds, []string{"cd", "go/src/gui/app/myrepos"})
- repos := myrepolist()
- for _, line := range repos {
- log.Warn("repo =", line)
- path, _, _, _ := splitLine(line)
- if doesExist("/home/jcarr/go/src/" + path) {
- continue
- }
- newCmds = append(newCmds, []string{"go", "get", "-v", path})
- }
-
- script = newCmds
- doit.Enable()
- setGitCommands()
- })
-
- groupvbox.NewButton("status.Update() all", func () {
- for _, repo := range allrepos {
- repo.status.Update()
- }
- })
-
- groupvbox.NewButton("rescan all", func () {
- for _, repo := range allrepos {
- repo.newScan()
- }
- })
-}
-
-
// This creates a window
func repoworld() {
reposwin = gadgets.NewBasicWindow(myGui, "autotypist for GO & git. it types faster than you can.")
@@ -190,120 +105,7 @@ func repoworld() {
box2 := reposwin.Box().NewBox("bw vbox", false)
globalBuildOptions(box2)
-
- // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
- group2 := box2.NewGroup("Global Reset Options")
- buildOptions := group2.NewGrid("buildOptions",2, 1)
-
- buildOptions.NewLabel("delete PERFECT")
- buildOptions.NewButton("Find", func () {
- log.Warn("delete every repo marked PERFECT")
- var newCmds [][]string
- for _, repo := range allrepos {
- status := repo.getStatus()
- if status == "PERFECT" {
- var line []string
- line = append(line, "rm", "-rf", "go/src/" + repo.path)
- newCmds = append(newCmds, line)
- }
- }
- script = newCmds
- doit.Enable()
- setGitCommands()
- })
-
- buildOptions.NewLabel("delete PERFECT")
- buildOptions.NewButton("Find", func () {
- log.Warn("delete every repo marked PERFECT")
- var newCmds [][]string
- for _, repo := range allrepos {
- status := repo.getStatus()
- if status == "PERFECT" {
- var line []string
- line = append(line, "rm", "-rf", "go/src/" + repo.path)
- newCmds = append(newCmds, line)
- }
- }
- script = newCmds
- doit.Enable()
- setGitCommands()
- })
-
- buildOptions.NewLabel("start over")
- buildOptions.NewButton("rm src & pkgs", func () {
- var newCmds [][]string
- var dirty bool = false
- for _, repo := range allrepos {
- status := repo.getStatus()
- if status == "dirty" {
- dirty = true
- break
- }
- }
- newCmds = append(newCmds, []string{"cd", "."})
- newCmds = append(newCmds, []string{"rm", "-rf", "go/src/"})
- newCmds = append(newCmds, []string{"chmod", "700", "-R", "go/pkg/"})
- newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"})
- if dirty {
- newCmds = append(newCmds, []string{"can't do this with dirty repos"})
- doit.Disable()
- } else {
- doit.Enable()
- }
- script = newCmds
- setGitCommands()
- })
-
- buildOptions.NewLabel("rebuild autotypist")
- buildOptions.NewButton("go get", func () {
- var newCmds [][]string
- newCmds = append(newCmds, []string{"cd", "."})
- newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/apps/"})
- newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/"})
- 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", "go.wit.com/gui/toolkits"})
- newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits/andlabs"})
- newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."})
- newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits/gocui"})
- newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."})
- newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits"})
- newCmds = append(newCmds, []string{"make"})
- newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"})
- newCmds = append(newCmds, []string{"make"})
- script = newCmds
- setGitCommands()
- doit.Enable()
- })
-
- buildOptions.NewSeparator("endStatusScans")
- buildOptions.NewSeparator("endStatusScans")
-
- buildOptions.NewLabel("cmd")
- cmds = buildOptions.NewLabel("ls")
-
- buildOptions.NewLabel("--dry-run")
- dryrun = buildOptions.NewButton("show commands", func () {
- if goMake("--dry-run") {
- log.Warn("EVERYTHING MIGHT HAVE WORKED")
- } else {
- log.Warn("EVERYTHING WILL NOT WORK")
- dryrun.Disable()
- }
- })
-
- buildOptions.NewLabel("Doit")
- doit = buildOptions.NewButton("run commands", func () {
- doit.Disable()
- log.Warn("should run the commands here")
- // true here means dryrun == true. it's confusingly named
- if goMake("--doit") {
- log.Warn("EVERYTHING WORKED")
- } else {
- log.Warn("EVERYTHING DID NOT WORK")
- }
- })
+ globalResetOptions(box2)
reposwin.Draw()
}
diff --git a/resetOptions.go b/resetOptions.go
new file mode 100644
index 0000000..b62cd84
--- /dev/null
+++ b/resetOptions.go
@@ -0,0 +1,124 @@
+package main
+
+import (
+ "go.wit.com/log"
+ "go.wit.com/gui/gui"
+)
+
+
+func globalResetOptions(box *gui.Node) {
+ group2 := box.NewGroup("Global Reset Options")
+ buildOptions := group2.NewGrid("buildOptions",2, 1)
+
+ buildOptions.NewLabel("global path reset")
+ // to globally reset paths:
+ // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
+ buildOptions.NewButton("Find", func () {
+ log.Warn("delete every repo marked PERFECT")
+ var newCmds [][]string
+ for _, repo := range allrepos {
+ status := repo.getStatus()
+ if status == "PERFECT" {
+ var line []string
+ line = append(line, "rm", "-rf", "go/src/" + repo.path)
+ newCmds = append(newCmds, line)
+ }
+ }
+ me.script = newCmds
+ doit.Enable()
+ setGitCommands()
+ })
+
+ buildOptions.NewLabel("delete PERFECT")
+ buildOptions.NewButton("Find", func () {
+ log.Warn("delete every repo marked PERFECT")
+ var newCmds [][]string
+ for _, repo := range allrepos {
+ status := repo.getStatus()
+ if status == "PERFECT" {
+ var line []string
+ line = append(line, "rm", "-rf", "go/src/" + repo.path)
+ newCmds = append(newCmds, line)
+ }
+ }
+ me.script = newCmds
+ doit.Enable()
+ setGitCommands()
+ })
+
+ buildOptions.NewLabel("start over")
+ buildOptions.NewButton("rm src & pkgs", func () {
+ var newCmds [][]string
+ var dirty bool = false
+ for _, repo := range allrepos {
+ status := repo.getStatus()
+ if status == "dirty" {
+ dirty = true
+ break
+ }
+ }
+ newCmds = append(newCmds, []string{"cd", "."})
+ newCmds = append(newCmds, []string{"rm", "-rf", "go/src/"})
+ newCmds = append(newCmds, []string{"chmod", "700", "-R", "go/pkg/"})
+ newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"})
+ if dirty {
+ newCmds = append(newCmds, []string{"can't do this with dirty repos"})
+ doit.Disable()
+ } else {
+ doit.Enable()
+ }
+ me.script = newCmds
+ setGitCommands()
+ })
+
+ buildOptions.NewLabel("rebuild autotypist")
+ buildOptions.NewButton("go get", func () {
+ var newCmds [][]string
+ newCmds = append(newCmds, []string{"cd", "."})
+ newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/apps/"})
+ newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/"})
+ 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", "go.wit.com/gui/toolkits"})
+ newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits/andlabs"})
+ newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."})
+ newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits/gocui"})
+ newCmds = append(newCmds, []string{"go", "get", "-v", "-u", "."})
+ newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/gui/toolkits"})
+ newCmds = append(newCmds, []string{"make"})
+ newCmds = append(newCmds, []string{"cd", "go/src/go.wit.com/apps/myrepos"})
+ newCmds = append(newCmds, []string{"make"})
+ me.script = newCmds
+ setGitCommands()
+ doit.Enable()
+ })
+
+ buildOptions.NewSeparator("endStatusScans")
+ buildOptions.NewSeparator("endStatusScans")
+
+ buildOptions.NewLabel("cmd")
+ cmds = buildOptions.NewLabel("ls")
+
+ buildOptions.NewLabel("--dry-run")
+ dryrun = buildOptions.NewButton("show commands", func () {
+ if goMake("--dry-run") {
+ log.Warn("EVERYTHING MIGHT HAVE WORKED")
+ } else {
+ log.Warn("EVERYTHING WILL NOT WORK")
+ dryrun.Disable()
+ }
+ })
+
+ buildOptions.NewLabel("Doit")
+ doit = buildOptions.NewButton("run commands", func () {
+ doit.Disable()
+ log.Warn("should run the commands here")
+ // true here means dryrun == true. it's confusingly named
+ if goMake("--doit") {
+ log.Warn("EVERYTHING WORKED")
+ } else {
+ log.Warn("EVERYTHING DID NOT WORK")
+ }
+ })
+}
diff --git a/structs.go b/structs.go
index b0c7d7d..23b845a 100644
--- a/structs.go
+++ b/structs.go
@@ -13,8 +13,19 @@ var reposwin *gadgets.BasicWindow
var reposbox *gui.Node
var reposgrid *gui.Node
var reposgroup *gui.Node
+
+var me repoType
+
+type repoType struct {
+ script [][]string
+ toMoveToBranch string // what the current working branch name is
+
+ mainBranch *gadgets.BasicCombobox
+ develBranch *gadgets.BasicCombobox
+ userBranch *gadgets.BasicCombobox
+}
+
var cmds *gui.Node
-var script [][]string
var doit *gui.Node
var dryrun *gui.Node
diff --git a/unix.go b/unix.go
index 30793d1..d045967 100644
--- a/unix.go
+++ b/unix.go
@@ -13,7 +13,7 @@ var repopath string = "/home/jcarr/"
// but doesn't do anything
func goMake(dryRun string) bool {
var workingPath string = "go/src"
- for _, line := range script {
+ for _, line := range me.script {
if len(line) == 0 {
continue
}
@@ -40,7 +40,7 @@ func goMake(dryRun string) bool {
}
if dryRun == "--doit" {
log.Warn("Actually RUN path =", path, "cmd =", cmd, s)
- err, b, output := repostatus.RunCmd(repopath, line)
+ err, b, output := repostatus.RunCmd(path, line)
if err != nil {
log.Info("ABEND EXECUTION")
log.Info("error =", err)
@@ -48,7 +48,7 @@ func goMake(dryRun string) bool {
log.Info("output =", output)
return false
}
- log.Warn("output was =", output)
+ // log.Warn("output was =", output)
continue
}
log.Warn("don't know what to do. dryRun ==", dryRun)
@@ -57,8 +57,20 @@ func goMake(dryRun string) bool {
return true
}
-func runCommands() bool {
- for _, line := range script {
+func setGitCommands() {
+ var tmp []string
+ // convert to displayable to the user text
+ for _, line := range me.script {
+ s := strings.Join(line, " ")
+ log.Warn("s =", s)
+ tmp = append(tmp, s)
+ }
+ cmds.Set(strings.Join(tmp, "\n"))
+}
+
+/*
+func runCommandsOld() bool {
+ for _, line := range me.script {
s := strings.Join(line, " ")
log.Warn("NEED TO RUN:", s)
err, b, output := repostatus.RunCmd(repopath, line)
@@ -74,15 +86,4 @@ func runCommands() bool {
}
return true
}
-
-func setGitCommands() {
- var tmp []string
- // convert to displayable to the user text
- for _, line := range script {
- s := strings.Join(line, " ")
- log.Warn("s =", s)
- tmp = append(tmp, s)
- }
- cmds.Set(strings.Join(tmp, "\n"))
-}
-
+*/