summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile2
-rw-r--r--main.go73
2 files changed, 71 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 1c870cb..cea6c72 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
all:
go build -v -x
- ./control-panel-vpn
+ ./myrepos
redomod:
rm -f go.*
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)
+}