2024-01-09 01:16:00 -06:00
|
|
|
// This is a simple example
|
|
|
|
package main
|
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
import (
|
2024-01-15 08:11:08 -06:00
|
|
|
"embed"
|
2024-01-18 00:58:14 -06:00
|
|
|
"os/user"
|
2024-01-09 10:21:58 -06:00
|
|
|
|
2024-01-09 02:00:51 -06:00
|
|
|
"go.wit.com/log"
|
|
|
|
|
2024-01-18 05:03:04 -06:00
|
|
|
"go.wit.com/gui"
|
2024-01-18 00:58:14 -06:00
|
|
|
"go.wit.com/lib/gadgets"
|
|
|
|
"go.wit.com/lib/gui/repostatus"
|
2024-01-09 01:16:00 -06:00
|
|
|
)
|
|
|
|
|
2024-01-15 21:11:28 -06:00
|
|
|
//go:embed resources/*
|
2024-01-15 08:11:08 -06:00
|
|
|
var resToolkit embed.FS
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
func main() {
|
2024-01-18 05:03:04 -06:00
|
|
|
me = new(repoType)
|
|
|
|
me.allrepos = make(map[*repo]string)
|
|
|
|
|
|
|
|
me.myGui = gui.New()
|
|
|
|
me.myGui.InitEmbed(resToolkit)
|
|
|
|
me.myGui.LoadToolkit("nocui")
|
|
|
|
me.myGui.Default()
|
2024-01-09 01:16:00 -06:00
|
|
|
|
2024-01-16 11:56:55 -06:00
|
|
|
autotypistWindow()
|
2024-01-17 04:31:13 -06:00
|
|
|
// repoworld()
|
2024-01-16 11:14:30 -06:00
|
|
|
log.Sleep(.3)
|
2024-01-17 20:52:07 -06:00
|
|
|
// hidePerfect()
|
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-18 00:58:14 -06:00
|
|
|
newRepo.showButton = 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-18 05:03:04 -06:00
|
|
|
newRepo.status = repostatus.New(me.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-16 11:14:30 -06:00
|
|
|
newRepo.hidden = false
|
2024-01-13 21:39:44 -06:00
|
|
|
newRepo.status.Update()
|
|
|
|
newRepo.newScan()
|
2024-01-18 05:03:04 -06:00
|
|
|
me.allrepos[newRepo] = path
|
2024-01-09 02:00:51 -06:00
|
|
|
}
|
|
|
|
|
2024-01-16 11:56:55 -06:00
|
|
|
func autotypistWindow() {
|
2024-01-17 20:52:07 -06:00
|
|
|
/*
|
2024-01-18 05:03:04 -06:00
|
|
|
me.autotypistWindow = gadgets.NewBasicWindow(me.myGui, "autotypist for GO & git. it types faster than you can.")
|
2024-01-18 00:58:14 -06:00
|
|
|
me.autotypistWindow.Make()
|
|
|
|
me.autotypistWindow.StandardExit()
|
2024-01-16 11:56:55 -06:00
|
|
|
|
2024-01-18 00:58:14 -06:00
|
|
|
box := me.autotypistWindow.Box()
|
|
|
|
me.autotypistWindow.Draw()
|
2024-01-17 20:52:07 -06:00
|
|
|
*/
|
2024-01-18 05:03:04 -06:00
|
|
|
win := me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
|
2024-01-17 20:52:07 -06:00
|
|
|
box := win.NewBox("bw hbox", true)
|
2024-01-16 11:56:55 -06:00
|
|
|
globalDisplayOptions(box)
|
|
|
|
globalBuildOptions(box)
|
|
|
|
globalResetOptions(box)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2024-01-09 01:16:00 -06:00
|
|
|
// This creates a window
|
2024-01-10 19:44:38 -06:00
|
|
|
func repoworld() {
|
2024-01-18 05:03:04 -06:00
|
|
|
reposwin = gadgets.NewBasicWindow(me.myGui, "All git repositories in ~/go/src/")
|
2024-01-14 10:36:46 -06:00
|
|
|
reposwin.Make()
|
|
|
|
|
|
|
|
reposbox = reposwin.Box().NewBox("bw vbox", false)
|
2024-01-18 00:58:14 -06:00
|
|
|
reposwin.Draw()
|
|
|
|
|
2024-01-14 10:36:46 -06:00
|
|
|
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)
|
2024-01-18 00:58:14 -06:00
|
|
|
if mbranch == "" {
|
|
|
|
mbranch = "master"
|
|
|
|
}
|
|
|
|
if dbranch == "" {
|
|
|
|
dbranch = "devel"
|
|
|
|
}
|
2024-01-13 23:27:46 -06:00
|
|
|
usr, _ := user.Current()
|
2024-01-18 00:58:14 -06:00
|
|
|
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 01:16:00 -06:00
|
|
|
}
|