gofmt autofix paths

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-18 00:58:14 -06:00
parent a2c47263e3
commit 8a80991bd5
8 changed files with 71 additions and 65 deletions

View File

@ -8,7 +8,7 @@ import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
) )
func doesExist(path string) bool { func doesExist(path string) bool {
@ -26,7 +26,7 @@ func globalBuildOptions(box *gui.Node) {
groupvbox := group1.NewBox("bw vbox", false) groupvbox := group1.NewBox("bw vbox", false)
// grouphbox := groupvbox.NewBox("bw hbox", true) // grouphbox := groupvbox.NewBox("bw hbox", true)
grid := groupvbox.NewGrid("buildOptions",2, 1) grid := groupvbox.NewGrid("buildOptions", 2, 1)
me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch") me.mainBranch = gadgets.NewBasicCombobox(grid, "default main branch")
me.mainBranch.AddText("guimain") me.mainBranch.AddText("guimain")
@ -47,12 +47,12 @@ func globalBuildOptions(box *gui.Node) {
guiBranch.AddText("guimaster") guiBranch.AddText("guimaster")
guiBranch.AddText("guidevel") guiBranch.AddText("guidevel")
guiBranch.AddText("jcarr") guiBranch.AddText("jcarr")
guiBranch.Custom = func () { guiBranch.Custom = func() {
me.toMoveToBranch = guiBranch.String() me.toMoveToBranch = guiBranch.String()
setCurrentBranch.Set("set all branches to " + me.toMoveToBranch) setCurrentBranch.Set("set all branches to " + me.toMoveToBranch)
me.mainBranch.Disable() me.mainBranch.Disable()
} }
setCurrentBranch = groupvbox.NewButton("set all branches to", func () { setCurrentBranch = groupvbox.NewButton("set all branches to", func() {
for _, repo := range allrepos { for _, repo := range allrepos {
var changeBranch [][]string var changeBranch [][]string
// realname, realversion := repo.status.CheckoutBranch(me.toMoveToBranch) // realname, realversion := repo.status.CheckoutBranch(me.toMoveToBranch)
@ -67,7 +67,7 @@ func globalBuildOptions(box *gui.Node) {
} }
}) })
var everything *gui.Node var everything *gui.Node
everything = groupvbox.NewButton("go get everything on go.wit.com", func () { everything = groupvbox.NewButton("go get everything on go.wit.com", func() {
var perfect bool = true var perfect bool = true
var newCmds [][]string var newCmds [][]string
// usr, _ := user.Current() // usr, _ := user.Current()
@ -103,6 +103,6 @@ func globalBuildOptions(box *gui.Node) {
doit.Enable() doit.Enable()
setGitCommands() setGitCommands()
}) })
groupvbox.NewButton("build all apps", func () { groupvbox.NewButton("build all apps", func() {
}) })
} }

View File

@ -13,7 +13,7 @@ func globalDisplayOptions(box *gui.Node) {
groupvbox := group1.NewBox("bw vbox", false) groupvbox := group1.NewBox("bw vbox", false)
// grouphbox := groupvbox.NewBox("bw hbox", true) // grouphbox := groupvbox.NewBox("bw hbox", true)
groupvbox.NewButton("Show Repository Window", func () { groupvbox.NewButton("Show Repository Window", func() {
reposwin.Draw() reposwin.Draw()
}) })
me.autoHidePerfect = groupvbox.NewCheckbox("Hide repos") me.autoHidePerfect = groupvbox.NewCheckbox("Hide repos")
@ -27,11 +27,11 @@ func globalDisplayOptions(box *gui.Node) {
} }
me.autoHidePerfect.Set(true) me.autoHidePerfect.Set(true)
groupvbox.NewButton("hide perfect", func () { groupvbox.NewButton("hide perfect", func() {
me.autoHidePerfect.SetText("Hide Perfectly clean repos") me.autoHidePerfect.SetText("Hide Perfectly clean repos")
hidePerfect() hidePerfect()
}) })
groupvbox.NewButton("show all", func () { groupvbox.NewButton("show all", func() {
for _, repo := range allrepos { for _, repo := range allrepos {
if repo.dirtyLabel.String() == "PERFECT" { if repo.dirtyLabel.String() == "PERFECT" {
if repo.hidden { if repo.hidden {
@ -42,25 +42,25 @@ func globalDisplayOptions(box *gui.Node) {
} }
}) })
groupvbox.NewButton("reposwin.Hide()", func () { groupvbox.NewButton("reposwin.Hide()", func() {
reposwin.Hide() reposwin.Hide()
}) })
groupvbox.NewButton("reposwin.Show()", func () { groupvbox.NewButton("reposwin.Show()", func() {
reposwin.Show() reposwin.Show()
}) })
groupvbox.NewButton("status.Update() all", func () { groupvbox.NewButton("status.Update() all", func() {
for _, repo := range allrepos { for _, repo := range allrepos {
repo.status.Update() repo.status.Update()
} }
}) })
groupvbox.NewButton("rescan all", func () { groupvbox.NewButton("rescan all", func() {
for _, repo := range allrepos { for _, repo := range allrepos {
repo.newScan() repo.newScan()
} }
}) })
groupvbox.NewButton("repoworld()", func () { groupvbox.NewButton("repoworld()", func() {
repoworld() repoworld()
}) })
} }

View File

@ -1,26 +1,25 @@
package main package main
import ( import (
"go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/log"
) )
func globalResetOptions(box *gui.Node) { func globalResetOptions(box *gui.Node) {
group2 := box.NewGroup("Global Destructive Options") group2 := box.NewGroup("Global Destructive Options")
buildOptions := group2.NewGrid("buildOptions",2, 1) buildOptions := group2.NewGrid("buildOptions", 2, 1)
buildOptions.NewLabel("global path reset") buildOptions.NewLabel("global path reset")
// to globally reset paths: // to globally reset paths:
// gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" . // gofmt -w -r "go.wit.com/gui -> go.wit.com/gui/gui" .
buildOptions.NewButton("Find", func () { buildOptions.NewButton("Find", func() {
log.Warn("delete every repo marked PERFECT") log.Warn("delete every repo marked PERFECT")
var newCmds [][]string var newCmds [][]string
for _, repo := range allrepos { for _, repo := range allrepos {
status := repo.getStatus() status := repo.getStatus()
if status == "PERFECT" { if status == "PERFECT" {
var line []string var line []string
line = append(line, "rm", "-rf", "go/src/" + repo.path) line = append(line, "rm", "-rf", "go/src/"+repo.path)
newCmds = append(newCmds, line) newCmds = append(newCmds, line)
} }
} }
@ -30,14 +29,14 @@ func globalResetOptions(box *gui.Node) {
}) })
buildOptions.NewLabel("delete PERFECT") buildOptions.NewLabel("delete PERFECT")
buildOptions.NewButton("Find", func () { buildOptions.NewButton("Find", func() {
log.Warn("delete every repo marked PERFECT") log.Warn("delete every repo marked PERFECT")
var newCmds [][]string var newCmds [][]string
for _, repo := range allrepos { for _, repo := range allrepos {
status := repo.getStatus() status := repo.getStatus()
if status == "PERFECT" { if status == "PERFECT" {
var line []string var line []string
line = append(line, "rm", "-rf", "go/src/" + repo.path) line = append(line, "rm", "-rf", "go/src/"+repo.path)
newCmds = append(newCmds, line) newCmds = append(newCmds, line)
} }
} }
@ -47,7 +46,7 @@ func globalResetOptions(box *gui.Node) {
}) })
buildOptions.NewLabel("start over") buildOptions.NewLabel("start over")
buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func () { buildOptions.NewButton("rm ~/go/src & ~/go/pkg", func() {
var newCmds [][]string var newCmds [][]string
var dirty bool = false var dirty bool = false
for _, repo := range allrepos { for _, repo := range allrepos {
@ -72,7 +71,7 @@ func globalResetOptions(box *gui.Node) {
}) })
buildOptions.NewLabel("rebuild autotypist") buildOptions.NewLabel("rebuild autotypist")
buildOptions.NewButton("go get", func () { buildOptions.NewButton("go get", func() {
var newCmds [][]string var newCmds [][]string
newCmds = append(newCmds, []string{"cd", "."}) newCmds = append(newCmds, []string{"cd", "."})
newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/apps/"}) newCmds = append(newCmds, []string{"mkdir", "-p", "go/src/go.wit.com/apps/"})
@ -101,7 +100,7 @@ func globalResetOptions(box *gui.Node) {
cmds = buildOptions.NewLabel("ls") cmds = buildOptions.NewLabel("ls")
buildOptions.NewLabel("--dry-run") buildOptions.NewLabel("--dry-run")
dryrun = buildOptions.NewButton("show commands", func () { dryrun = buildOptions.NewButton("show commands", func() {
if goMake("--dry-run") { if goMake("--dry-run") {
log.Warn("EVERYTHING MIGHT HAVE WORKED") log.Warn("EVERYTHING MIGHT HAVE WORKED")
} else { } else {
@ -111,7 +110,7 @@ func globalResetOptions(box *gui.Node) {
}) })
buildOptions.NewLabel("Doit") buildOptions.NewLabel("Doit")
doit = buildOptions.NewButton("run commands", func () { doit = buildOptions.NewButton("run commands", func() {
doit.Disable() doit.Disable()
log.Warn("should run the commands here") log.Warn("should run the commands here")
// true here means dryrun == true. it's confusingly named // true here means dryrun == true. it's confusingly named

23
main.go
View File

@ -2,14 +2,14 @@
package main package main
import ( import (
"os/user"
"embed" "embed"
"os/user"
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/gui/lib/repostatus" "go.wit.com/lib/gui/repostatus"
) )
//go:embed resources/* //go:embed resources/*
@ -51,7 +51,7 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion") newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
newRepo.dirtyLabel = grid.NewLabel("") newRepo.dirtyLabel = grid.NewLabel("")
newRepo.showButton = grid.NewButton("Show()", func () { newRepo.showButton = grid.NewButton("Show()", func() {
if newRepo.status == nil { if newRepo.status == nil {
log.Warn("status window doesn't exist") log.Warn("status window doesn't exist")
return return
@ -97,6 +97,8 @@ func repoworld() {
reposwin.Make() reposwin.Make()
reposbox = reposwin.Box().NewBox("bw vbox", false) reposbox = reposwin.Box().NewBox("bw vbox", false)
reposwin.Draw()
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)") reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
reposgrid = reposgroup.NewGrid("test", 11, 1) reposgrid = reposgroup.NewGrid("test", 11, 1)
@ -116,11 +118,16 @@ func repoworld() {
for _, line := range repos { for _, line := range repos {
log.Warn("repo =", line) log.Warn("repo =", line)
path, mbranch, dbranch, ubranch := splitLine(line) path, mbranch, dbranch, ubranch := splitLine(line)
if mbranch == "" { mbranch = "master" } if mbranch == "" {
if dbranch == "" { dbranch = "devel" } mbranch = "master"
}
if dbranch == "" {
dbranch = "devel"
}
usr, _ := user.Current() usr, _ := user.Current()
if ubranch == "" { ubranch = usr.Username } if ubranch == "" {
ubranch = usr.Username
}
addRepo(reposgrid, path, mbranch, dbranch, ubranch) addRepo(reposgrid, path, mbranch, dbranch, ubranch)
} }
reposwin.Draw()
} }

View File

@ -4,7 +4,7 @@ package main
import ( import (
"go.wit.com/log" "go.wit.com/log"
"go.wit.com/gui/lib/repostatus" "go.wit.com/lib/gui/repostatus"
) )
func (r *repo) newScan() bool { func (r *repo) newScan() bool {

View File

@ -3,8 +3,8 @@ package main
import ( import (
"go.wit.com/gui/gui" "go.wit.com/gui/gui"
"go.wit.com/gui/gadgets" "go.wit.com/lib/gadgets"
"go.wit.com/gui/lib/repostatus" "go.wit.com/lib/gui/repostatus"
) )
// the main window nodes // the main window nodes

View File

@ -1,10 +1,10 @@
package main package main
import ( import (
"strings"
"go.wit.com/log" "go.wit.com/log"
"strings"
"go.wit.com/gui/lib/repostatus" "go.wit.com/lib/gui/repostatus"
) )
var repopath string = "/home/jcarr/" var repopath string = "/home/jcarr/"
@ -20,7 +20,7 @@ func goMake(dryRun string) bool {
if line[0] == "cd" { if line[0] == "cd" {
switch len(line) { switch len(line) {
case 1: case 1:
log.Verbose("do cmdPwd() to go root", repopath + "go/src") log.Verbose("do cmdPwd() to go root", repopath+"go/src")
workingPath = "" workingPath = ""
case 2: case 2:
log.Verbose("do cmdPwd() here", line) log.Verbose("do cmdPwd() here", line)