summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2024-01-09 02:00:51 -0600
committerJeff Carr <[email protected]>2024-01-09 02:00:51 -0600
commit96379b62795dfaabae415ff469942d77ea8f2817 (patch)
tree5fae7b4ac3711c4c6f645cc2915e444887ffeb69 /main.go
parenta0be4a93d1776ef2b173edecbf6aef11ba910ad7 (diff)
get git version
Signed-off-by: Jeff Carr <[email protected]>
Diffstat (limited to 'main.go')
-rw-r--r--main.go73
1 files changed, 70 insertions, 3 deletions
diff --git a/main.go b/main.go
index a5cbd2c..2ce67a1 100644
--- a/main.go
+++ b/main.go
@@ -2,7 +2,11 @@
package main
import (
- "log"
+ "strings"
+ "os/exec"
+
+ "go.wit.com/log"
+
"go.wit.com/gui/gui"
"go.wit.com/gui/gadgets"
"go.wit.com/apps/control-panel-dns/smartwindow"
@@ -19,11 +23,54 @@ func main() {
gui.Watchdog()
}
+func addRepo(grid *gui.Node, path string) {
+ grid.NewLabel(path)
+ ver := grid.NewLabel("VERSION")
+ b, out := run(path, "git", "describe --tags")
+ if b {
+ ver.SetText(out)
+ }
+
+ // cmd := "dig +noall +answer www.wit.com A"
+ // out = shell.Run(cmd)
+ grid.NewLabel("jcarr")
+ grid.NewLabel("dirty")
+
+ grid.NewButton("commit", func () {
+ log.Println("world")
+ hellosmart()
+ })
+ grid.NewButton("push", func () {
+ log.Println("world")
+ hellosmart()
+ })
+
+}
+
// This creates a window
func helloworld() {
win := gadgets.NewBasicWindow(myGui, "helloworld golang wit/gui window")
- win.Box().NewButton("hello", func () {
+ box := win.Box().NewBox("bw vbox", false)
+ group := box.NewGroup("test")
+ grid := group.NewGrid("test", 6, 1)
+
+ grid.NewLabel("Repo")
+ grid.NewLabel("Version")
+ grid.NewLabel("Current branch")
+ grid.NewLabel("is dirty?")
+ grid.NewLabel("commit")
+ grid.NewLabel("push to")
+
+ addRepo(grid, "go.wit.com/log")
+ addRepo(grid, "go.wit.com/arg")
+ addRepo(grid, "go.wit.com/spew")
+ addRepo(grid, "go.wit.com/shell")
+ addRepo(grid, "")
+ addRepo(grid, "go.wit.com/gui/gadgets")
+ addRepo(grid, "go.wit.com/gui/gadgets")
+
+ box.NewButton("hello", func () {
log.Println("world")
hellosmart()
})
@@ -39,7 +86,7 @@ func hellosmart() {
win.SetDraw(smartDraw)
win.Make()
- win.Box().NewButton("hello", func () {
+ win.Box().NewButton("test smartwindow", func () {
log.Println("smart")
})
}
@@ -49,3 +96,23 @@ func smartDraw(sw *smartwindow.SmartWindow) {
log.Println("smart")
})
}
+
+func run(path string, thing string, cmdline string) (bool, string) {
+ parts := strings.Split(cmdline, " ")
+ // Create the command
+ cmd := exec.Command(thing, parts...)
+
+ // Set the working directory
+ cmd.Dir = "/home/jcarr/go/src/" + path
+
+ // Execute the command
+ output, err := cmd.CombinedOutput()
+ if err != nil {
+ log.Error(err, "cmd error'd out", parts)
+ return false, ""
+ }
+
+ // Print the output
+ log.Info(string(output))
+ return true, string(output)
+}