2024-01-09 01:16:00 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2024-01-13 23:27:46 -06:00
|
|
|
"os/user"
|
2024-01-15 08:11:08 -06:00
|
|
|
"embed"
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
"go.wit.com/gui/gui"
|
|
|
|
"go.wit.com/gui/gadgets"
|
2024-01-15 12:43:08 -06:00
|
|
|
"go.wit.com/gui/tools/repostatus"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
//go:embed plugins/*
|
|
|
|
var resToolkit embed.FS
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
func main() {
|
2024-01-15 08:11:08 -06:00
|
|
|
myGui = gui.New()
|
|
|
|
myGui.InitEmbed(resToolkit)
|
|
|
|
myGui.Default()
|
2024-01-09 01:16:00 -06:00
|
|
|
|
2024-01-10 19:44:38 -06:00
|
|
|
repoworld()
|
2024-01-09 01:16:00 -06:00
|
|
|
gui.Watchdog()
|
|
|
|
}
|
|
|
|
|
2024-01-13 23:27:46 -06:00
|
|
|
func addRepo(grid *gui.Node, path string, master string, devel string, user string) {
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo := new(repo)
|
|
|
|
|
2024-01-13 21:39:44 -06:00
|
|
|
if repostatus.VerifyLocalGoRepo(path) {
|
|
|
|
log.Warn("newRepo actually exists", newRepo.getPath())
|
|
|
|
} else {
|
|
|
|
log.Warn("newRepo does not exist", newRepo.getPath())
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2024-01-09 02:22:01 -06:00
|
|
|
newRepo.path = path
|
2024-01-15 08:11:08 -06:00
|
|
|
newRepo.pLabel = grid.NewLabel(path).SetProgName("path")
|
|
|
|
newRepo.lastTag = grid.NewLabel("").SetProgName("lastTag")
|
|
|
|
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
|
|
|
|
|
|
|
|
newRepo.masterName = grid.NewLabel("").SetProgName("masterName")
|
|
|
|
newRepo.masterVersion = grid.NewLabel("").SetProgName("masterVersion")
|
|
|
|
newRepo.develName = grid.NewLabel("").SetProgName("develName")
|
|
|
|
newRepo.develVersion = grid.NewLabel("").SetProgName("develVersion")
|
|
|
|
newRepo.userName = grid.NewLabel("").SetProgName("userName")
|
|
|
|
newRepo.userVersion = grid.NewLabel("").SetProgName("userVersion")
|
2024-01-09 09:56:33 -06:00
|
|
|
newRepo.dirtyLabel = grid.NewLabel("")
|
2024-01-09 02:22:01 -06:00
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
/*
|
2024-01-11 15:57:08 -06:00
|
|
|
newRepo.pButton = grid.NewButton("rescan", func () {
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.newScan()
|
|
|
|
})
|
|
|
|
|
2024-01-14 21:43:31 -06:00
|
|
|
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()
|
|
|
|
})
|
2024-01-14 13:29:24 -06:00
|
|
|
grid.NewButton("Hide()", func () {
|
2024-01-13 21:39:44 -06:00
|
|
|
if newRepo.status == nil {
|
|
|
|
log.Warn("status window doesn't exist")
|
|
|
|
return
|
|
|
|
}
|
2024-01-14 13:29:24 -06:00
|
|
|
log.Warn("status window exists. trying Hide() here")
|
|
|
|
newRepo.status.Hide()
|
2024-01-13 21:39:44 -06:00
|
|
|
})
|
2024-01-15 08:11:08 -06:00
|
|
|
*/
|
2024-01-14 10:25:21 -06:00
|
|
|
grid.NewButton("Show()", func () {
|
2024-01-13 21:39:44 -06:00
|
|
|
if newRepo.status == nil {
|
|
|
|
log.Warn("status window doesn't exist")
|
|
|
|
return
|
|
|
|
}
|
|
|
|
log.Warn("status window exists. trying TestDraw() here")
|
2024-01-14 10:25:21 -06:00
|
|
|
newRepo.status.Show()
|
2024-01-14 22:15:02 -06:00
|
|
|
newRepo.status.Update()
|
2024-01-09 02:00:51 -06:00
|
|
|
})
|
2024-01-10 19:44:38 -06:00
|
|
|
if path == "" {
|
|
|
|
newRepo.cButton.Hide()
|
|
|
|
newRepo.pButton.Hide()
|
|
|
|
}
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.status = repostatus.New(myGui, newRepo.path)
|
2024-01-13 23:27:46 -06:00
|
|
|
newRepo.status.SetMasterName(master)
|
|
|
|
newRepo.status.SetDevelName(devel)
|
|
|
|
newRepo.status.SetUserName(user)
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.status.Update()
|
|
|
|
newRepo.newScan()
|
2024-01-09 02:22:01 -06:00
|
|
|
allrepos = append(allrepos, newRepo)
|
2024-01-09 02:00:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
// This creates a window
|
2024-01-10 19:44:38 -06:00
|
|
|
func repoworld() {
|
2024-01-15 12:43:08 -06:00
|
|
|
reposwin = gadgets.NewBasicWindow(myGui, "autotypist for GO & git. it types faster than you can.")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposwin.Make()
|
|
|
|
|
|
|
|
reposbox = reposwin.Box().NewBox("bw vbox", false)
|
|
|
|
reposgroup = reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
|
2024-01-15 08:11:08 -06:00
|
|
|
reposgrid = reposgroup.NewGrid("test", 11, 1)
|
2024-01-14 10:36:46 -06:00
|
|
|
|
|
|
|
reposgrid.NewLabel("")
|
2024-01-15 08:11:08 -06:00
|
|
|
reposgrid.NewLabel("last tag").SetProgName("last tag")
|
|
|
|
reposgrid.NewLabel("Current Version").SetProgName("Current Version")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgrid.NewLabel("master")
|
2024-01-14 13:29:24 -06:00
|
|
|
reposgrid.NewLabel("version")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgrid.NewLabel("devel")
|
2024-01-14 13:29:24 -06:00
|
|
|
reposgrid.NewLabel("version")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgrid.NewLabel("user")
|
2024-01-14 13:29:24 -06:00
|
|
|
reposgrid.NewLabel("version")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposgrid.NewLabel("Status")
|
2024-01-14 21:43:31 -06:00
|
|
|
reposgrid.NewLabel("Show()")
|
2024-01-09 02:00:51 -06:00
|
|
|
|
2024-01-09 10:41:35 -06:00
|
|
|
repos := myrepolist()
|
2024-01-13 23:27:46 -06:00
|
|
|
for _, line := range repos {
|
|
|
|
log.Warn("repo =", line)
|
|
|
|
path, mbranch, dbranch, ubranch := splitLine(line)
|
|
|
|
if mbranch == "" { mbranch = "master" }
|
|
|
|
if dbranch == "" { dbranch = "devel" }
|
|
|
|
usr, _ := user.Current()
|
|
|
|
if ubranch == "" { ubranch = usr.Username }
|
2024-01-14 10:36:46 -06:00
|
|
|
addRepo(reposgrid, path, mbranch, dbranch, ubranch)
|
2024-01-09 10:21:58 -06:00
|
|
|
}
|
2024-01-09 11:55:18 -06:00
|
|
|
|
2024-01-14 10:36:46 -06:00
|
|
|
box2 := reposwin.Box().NewBox("bw vbox", false)
|
2024-01-15 08:11:08 -06:00
|
|
|
|
|
|
|
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")
|
|
|
|
|
|
|
|
buildOptions.NewLabel("only 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
|
|
|
|
}
|
|
|
|
}
|
|
|
|
line := []string{"rm", "-rf", "go/src/"}
|
|
|
|
newCmds = append(newCmds, line)
|
|
|
|
newCmds = append(newCmds, []string{"rm", "-rf", "go/pkg/"})
|
|
|
|
if dirty {
|
|
|
|
line := []string{"can't do this with dirty repos"}
|
|
|
|
newCmds = append(newCmds, line)
|
|
|
|
doit.Disable()
|
|
|
|
} else {
|
|
|
|
doit.Enable()
|
|
|
|
}
|
|
|
|
script = newCmds
|
|
|
|
setGitCommands()
|
2024-01-14 01:59:19 -06:00
|
|
|
})
|
|
|
|
|
2024-01-15 08:21:23 -06:00
|
|
|
buildOptions.NewLabel("get autotypist")
|
|
|
|
buildOptions.NewButton("go get", func () {
|
|
|
|
var newCmds [][]string
|
2024-01-15 12:43:08 -06:00
|
|
|
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"})
|
2024-01-15 08:21:23 -06:00
|
|
|
script = newCmds
|
|
|
|
setGitCommands()
|
|
|
|
doit.Enable()
|
2024-01-15 08:11:08 -06:00
|
|
|
})
|
|
|
|
|
|
|
|
buildOptions.NewButton("status.Update() all", func () {
|
2024-01-14 01:59:19 -06:00
|
|
|
for _, repo := range allrepos {
|
|
|
|
repo.status.Update()
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
buildOptions.NewButton("rescan all", func () {
|
2024-01-14 01:59:19 -06:00
|
|
|
for _, repo := range allrepos {
|
|
|
|
repo.newScan()
|
|
|
|
}
|
|
|
|
})
|
2024-01-15 08:11:08 -06:00
|
|
|
buildOptions.NewLabel("cmd")
|
|
|
|
cmds = buildOptions.NewLabel("ls")
|
|
|
|
|
2024-01-15 12:43:08 -06:00
|
|
|
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")
|
|
|
|
}
|
|
|
|
})
|
|
|
|
|
2024-01-15 08:11:08 -06:00
|
|
|
buildOptions.NewLabel("Doit")
|
|
|
|
doit = buildOptions.NewButton("run commands", func () {
|
|
|
|
doit.Disable()
|
|
|
|
log.Warn("should run the commands here")
|
|
|
|
if runCommands() {
|
|
|
|
log.Warn("EVERYTHING WORKED")
|
|
|
|
} else {
|
|
|
|
log.Warn("EVERYTHING DID NOT WORK")
|
|
|
|
}
|
|
|
|
})
|
2024-01-14 01:59:19 -06:00
|
|
|
|
2024-01-14 10:36:46 -06:00
|
|
|
reposwin.Draw()
|
2024-01-09 01:16:00 -06:00
|
|
|
}
|