add a git commit button. I used it for this commit

This commit is contained in:
Jeff Carr 2024-02-12 15:24:35 -06:00
parent cdc5743e67
commit 4555b9f34d
9 changed files with 119 additions and 32 deletions

10
args.go
View File

@ -12,15 +12,11 @@ import (
"go.wit.com/log"
)
// GadgetDisplay string `arg:"env:DISPLAY"`
// GadgetTmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
// GadgetVerboseDNS bool `arg:"--verbose" help:"debug your dns settings"`
var args struct {
DownloadAll bool `arg:"--download-all" help:"download everything from go.wit.com"`
GitPull bool `arg:"--git-pull" help:"do git pull in every repository"`
CheckoutUser bool `arg:"--switch-to-user-branch" help:"switch everything to your user branch"`
CheckoutDevel bool `arg:"--switch-to-devel-branch" help:"switch everything to the devel branch"`
TmpLog bool `arg:"--tmp-log" help:"automatically send STDOUT to /tmp"`
}
func init() {
@ -28,7 +24,9 @@ func init() {
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
} else {
log.Info("cmd line --debugger == false")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

View File

@ -54,8 +54,7 @@ func quickCmd(fullpath string, cmd []string) bool {
return true
}
func globalBuildOptions(box *gui.Node) {
vbox := box.NewVerticalBox("DISPLAYVBOX")
func globalBuildOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Build Options")
grid := group1.NewGrid("buildOptions", 2, 1)

View File

@ -47,9 +47,7 @@ func globalDisplayShow() {
}
}
func globalDisplayOptions(box *gui.Node) {
vbox := box.NewVerticalBox("DISPLAYVBOX")
func globalDisplayOptions(vbox *gui.Node) {
group1 := vbox.NewGroup("Global Display Options")
group1.NewButton("Show Repository Window", func() {
@ -123,7 +121,9 @@ func globalDisplayOptions(box *gui.Node) {
}
listallB.Enable()
})
}
func debuggerBox(vbox *gui.Node) {
group2 := vbox.NewGroup("Debugger")
group2.NewButton("logging Window", func() {
logsettings.LogWindow()

15
main.go
View File

@ -16,11 +16,6 @@ func main() {
me = new(autoType)
me.allrepos = make(map[string]*repo)
if args.TmpLog {
// send all log() output to a file in /tmp
log.SetTmp()
}
me.myGui = gui.New()
me.myGui.InitEmbed(resToolkit)
me.myGui.Default()
@ -28,8 +23,14 @@ func main() {
me.autotypistWindow = me.myGui.NewWindow("autotypist for GO & git. it types faster than you can.")
box := me.autotypistWindow.NewBox("bw hbox", true)
globalDisplayOptions(box)
globalBuildOptions(box)
vbox1 := box.NewVerticalBox("BOX1")
globalDisplayOptions(vbox1)
debuggerBox(vbox1)
vbox2 := box.NewVerticalBox("BOX2")
globalBuildOptions(vbox2)
summaryBox(vbox2)
globalResetOptions(box)
repolistWindow()

0
nohup.out Normal file
View File

View File

@ -60,7 +60,9 @@ func (r *repo) Hide() {
r.userVersion.Hide()
r.dirtyLabel.Hide()
r.statusButton.Hide()
r.endBox.Hide()
// r.statusButton.Hide()
// r.diffButton.Hide()
r.hidden = true
}
@ -74,7 +76,9 @@ func (r *repo) Show() {
r.userVersion.Show()
r.dirtyLabel.Show()
r.statusButton.Show()
r.endBox.Show()
// r.statusButton.Show()
// r.diffButton.Show()
r.hidden = false
}
@ -113,15 +117,40 @@ func addRepo(grid *gui.Node, path string, master string, devel string, user stri
newRepo.vLabel = grid.NewLabel("").SetProgName("current")
newRepo.statusButton = grid.NewButton("Configure", func() {
newRepo.endBox = grid.NewHorizontalBox("HBOX")
newRepo.endBox.NewButton("Configure", func() {
if newRepo.status == nil {
log.Warn("status window doesn't exist")
log.Warn("status window wasn't created")
return
}
log.Warn("status window exists. trying TestDraw() here")
newRepo.status.Toggle()
})
newRepo.endBox.NewButton("show diff", func() {
me.reposwin.Disable()
newRepo.status.XtermNohup([]string{"git diff"})
me.reposwin.Enable()
})
newRepo.endBox.NewButton("commit all", func() {
me.reposwin.Disable()
// restore anything staged so everything can be reviewed
newRepo.status.Xterm([]string{"git restore --staged ."})
// newRepo.status.Xterm([]string{"git diff"})
newRepo.status.Xterm([]string{"git add --all"})
newRepo.status.XtermNohup([]string{"git diff --cached"})
newRepo.status.Xterm([]string{"git commit -a"})
if newRepo.status.CheckDirty() {
// commit was not done, restore diff
newRepo.status.Xterm([]string{"git restore --staged ."})
} else {
newRepo.status.Update()
newRepo.newScan()
}
me.reposwin.Enable()
})
newRepo.status = repostatus.NewRepoStatusWindow(newRepo.path)
newRepo.hidden = false
newRepo.status.SetMainWorkingName(master)
@ -146,7 +175,7 @@ func repolistWindow() {
repoAllButtons(me.reposbox)
me.reposgroup = me.reposbox.NewGroup("go repositories (read from ~/.config/myrepolist)")
me.reposgrid = me.reposgroup.NewGrid("test", 8, 1)
me.reposgrid = me.reposgroup.NewGrid("test", 0, 0)
me.reposgrid.NewLabel("") // path goes here
@ -159,8 +188,7 @@ func repolistWindow() {
me.reposgrid.NewLabel("Status")
me.reposgrid.NewLabel("Current Version").SetProgName("Current Version")
me.reposgrid.NewLabel("Show()")
me.reposgrid.NextRow()
usr, _ := user.Current()
@ -178,6 +206,7 @@ func repolistWindow() {
ubranch = usr.Username
}
addRepo(me.reposgrid, path, mbranch, dbranch, ubranch)
me.reposgrid.NextRow()
}
// TODO: figure out why this borks everything

View File

@ -15,9 +15,9 @@ type autoType struct {
autotypistWindow *gui.Node
reposwin *gadgets.BasicWindow
reposbox *gui.Node
reposgrid *gui.Node
reposwin *gadgets.BasicWindow
reposbox *gui.Node
reposgrid *gui.Node
reposgroup *gui.Node
// #### autotypist Global Display Options
@ -83,7 +83,9 @@ type repo struct {
develVersion *gui.Node // the devel branch version
userVersion *gui.Node // the user branch version
endBox *gui.Node // a general box at the end of the row
statusButton *gui.Node // opens up the status window
diffButton *gui.Node // opens up the status window
status *repostatus.RepoStatus
}

57
summaryBox.go Normal file
View File

@ -0,0 +1,57 @@
// This is a simple example
package main
import (
"fmt"
"os"
"path/filepath"
"go.wit.com/gui"
"go.wit.com/lib/gui/shell"
"go.wit.com/log"
// "go.wit.com/gui/gadgets"
)
func summaryBox(box *gui.Node) {
group1 := box.NewGroup("Repository Summary")
grid := group1.RawGrid()
grid.NewButton("Show Repository Window", func() {
globalDisplaySetRepoState()
// reposwin.Toggle()
})
grid.NewButton("open docs (localhost:8080)", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
goSrcDir := me.goSrcPwd.String()
filename := filepath.Join(goSrcDir, "go.work")
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE, 0600)
if err != nil {
return
}
defer f.Close()
fmt.Fprintln(f, "go 1.21.4")
fmt.Fprintln(f, "")
fmt.Fprintln(f, "use (")
for _, repo := range me.allrepos {
if repo.status.Exists("go.mod") {
fmt.Fprintln(f, "\t"+repo.String())
} else {
log.Info("missing go.mod for", repo.String())
repo.status.MakeRedomod()
}
}
fmt.Fprintln(f, ")")
tmp := me.userHomePwd.String()
tmpDir := filepath.Join(tmp, "go/src")
os.Chdir(tmpDir)
pkgsite := filepath.Join(tmp, "go/bin", "pkgsite")
os.Unsetenv("GO111MODULE")
go shell.Run([]string{pkgsite})
shell.Run([]string{"ping", "-c", "3", "git.wit.org"})
shell.OpenBrowser("http://localhost:8080")
})
}

View File

@ -39,10 +39,11 @@ func makeTagWindow() *tagWindow {
tagW.win.Draw()
tagW.box = tagW.win.Box()
topGrid := tagW.box.RawGrid()
tagW.group = tagW.box.NewGroup("tags")
tagW.grid = tagW.box.RawGrid()
tagW.group.NewButton("list all tags", func() {
topGrid.NewButton("list all tags", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
for _, repo := range me.allrepos {
@ -58,9 +59,9 @@ func makeTagWindow() *tagWindow {
log.Info("found tag:", t.TagString(), "from", repo.status.String())
}
}
})
}).SetProgName("TAGSLISTALL")
tagW.group.NewButton("delete all dup tags", func() {
topGrid.NewButton("delete all dup tags", func() {
me.autotypistWindow.Disable()
defer me.autotypistWindow.Enable()
for _, repo := range me.allrepos {