diff --git a/main.go b/main.go index dff4d4c..5cff189 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( + "os" "os/user" "embed" @@ -91,6 +92,68 @@ 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.") @@ -126,17 +189,30 @@ func repoworld() { box2 := reposwin.Box().NewBox("bw vbox", false) - buildOptions := box2.NewGrid("buildOptions",2, 1) - title := gadgets.NewOneLiner(buildOptions, "Branch and build") - title.Set("options") - guiBranch := gadgets.NewBasicCombobox(buildOptions, "Select GUI branch") - guiBranch.Add("guimaster") - guiBranch.Add("guidevel") - guiBranch.Add("jcarr") + 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("only PERFECT") + 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 @@ -178,7 +254,7 @@ func repoworld() { setGitCommands() }) - buildOptions.NewLabel("get autotypist") + buildOptions.NewLabel("rebuild autotypist") buildOptions.NewButton("go get", func () { var newCmds [][]string newCmds = append(newCmds, []string{"cd", "."}) @@ -201,17 +277,6 @@ func repoworld() { doit.Enable() }) - buildOptions.NewButton("status.Update() all", func () { - for _, repo := range allrepos { - repo.status.Update() - } - }) - - buildOptions.NewButton("rescan all", func () { - for _, repo := range allrepos { - repo.newScan() - } - }) buildOptions.NewSeparator("endStatusScans") buildOptions.NewSeparator("endStatusScans")