something, something, GUI codebase
This commit is contained in:
parent
d00e96e354
commit
a29a774aa4
6
argv.go
6
argv.go
|
@ -79,8 +79,8 @@ func (args) doBashHelp() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (args) doBashAuto() {
|
func (args) DoAutoComplete(argv []string) {
|
||||||
switch argv.BashAuto[0] {
|
switch argv[0] {
|
||||||
case "list":
|
case "list":
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
case "verify":
|
case "verify":
|
||||||
|
@ -88,7 +88,7 @@ func (args) doBashAuto() {
|
||||||
case "upgrade":
|
case "upgrade":
|
||||||
fmt.Println("")
|
fmt.Println("")
|
||||||
default:
|
default:
|
||||||
if argv.BashAuto[0] == ARGNAME {
|
if argv[0] == ARGNAME {
|
||||||
// list the subcommands here
|
// list the subcommands here
|
||||||
fmt.Println("help list")
|
fmt.Println("help list")
|
||||||
}
|
}
|
||||||
|
|
24
doGui.go
24
doGui.go
|
@ -7,10 +7,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os"
|
"os"
|
||||||
"time"
|
|
||||||
|
|
||||||
"go.wit.com/gui"
|
|
||||||
"go.wit.com/lib/fhelp"
|
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
|
@ -38,21 +35,6 @@ func refresh() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func doGui() {
|
func doGui() {
|
||||||
me.myGui = gui.New()
|
|
||||||
me.myGui.SetAppDefaultPlugin("gocui") // sets the default GUI plugin to use
|
|
||||||
if pname, err := me.myGui.Default(); err != nil {
|
|
||||||
if !fhelp.BuildPlugin("gocui") {
|
|
||||||
log.Info("You can't run the forge GUI since the plugins did not build", pname)
|
|
||||||
okExit("")
|
|
||||||
} else {
|
|
||||||
if err := me.myGui.LoadToolkitNew("gocui"); err != nil {
|
|
||||||
log.Info("The plugins built, but still failed to load", pname)
|
|
||||||
badExit(err)
|
|
||||||
}
|
|
||||||
log.Info("The plugins built and loaded!", pname)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
win := gadgets.RawBasicWindow("Zookeeper: (inventory your cluster)")
|
win := gadgets.RawBasicWindow("Zookeeper: (inventory your cluster)")
|
||||||
win.Make()
|
win.Make()
|
||||||
win.Show()
|
win.Show()
|
||||||
|
@ -84,12 +66,6 @@ func doGui() {
|
||||||
grid.NewButton("ConfigSave()", func() {
|
grid.NewButton("ConfigSave()", func() {
|
||||||
saveMachineState()
|
saveMachineState()
|
||||||
})
|
})
|
||||||
|
|
||||||
// sit here forever refreshing the GUI
|
|
||||||
for {
|
|
||||||
refresh()
|
|
||||||
time.Sleep(90 * time.Second)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func saveMachineState() {
|
func saveMachineState() {
|
||||||
|
|
36
main.go
36
main.go
|
@ -8,8 +8,7 @@ import (
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/gui"
|
"go.wit.com/lib/gui/prep"
|
||||||
"go.wit.com/lib/fhelp"
|
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
"go.wit.com/log"
|
"go.wit.com/log"
|
||||||
)
|
)
|
||||||
|
@ -21,29 +20,10 @@ var ARGNAME string = "zookeeper"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
me = new(mainType)
|
me = new(mainType)
|
||||||
gui.InitArg()
|
prep.Bash(ARGNAME, argv.DoAutoComplete) // this line should be: prep.Bash(argv)
|
||||||
|
me.myGui = prep.Gui() // prepares the GUI package for go-args
|
||||||
me.pp = arg.MustParse(&argv)
|
me.pp = arg.MustParse(&argv)
|
||||||
|
|
||||||
if argv.Bash {
|
|
||||||
fhelp.DoBash(ARGNAME)
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
if len(argv.BashAuto) != 0 {
|
|
||||||
argv.doBashAuto()
|
|
||||||
os.Exit(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if the binary is being called to test
|
|
||||||
// if the plugin can actually loaded. This is a hack
|
|
||||||
// around needing a Test() plugin load function in GO
|
|
||||||
if gui.IsGoPluginTestHack() {
|
|
||||||
argv.NoPort = true
|
|
||||||
gui.CheckPlugin()
|
|
||||||
os.Exit(0)
|
|
||||||
// if argv.GuiCheck != "" {
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
if argv.Daemon {
|
if argv.Daemon {
|
||||||
// turn off timestamps for STDOUT (systemd adds them)
|
// turn off timestamps for STDOUT (systemd adds them)
|
||||||
log.DaemonMode(true)
|
log.DaemonMode(true)
|
||||||
|
@ -65,5 +45,13 @@ func main() {
|
||||||
if !argv.NoPort {
|
if !argv.NoPort {
|
||||||
go startHTTP()
|
go startHTTP()
|
||||||
}
|
}
|
||||||
doGui()
|
|
||||||
|
me.myGui.Start() // loads the GUI toolkit
|
||||||
|
doGui() // start making our forge GUI
|
||||||
|
|
||||||
|
// sit here forever refreshing the GUI
|
||||||
|
for {
|
||||||
|
refresh()
|
||||||
|
time.Sleep(90 * time.Second)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"go.wit.com/dev/alexflint/arg"
|
"go.wit.com/dev/alexflint/arg"
|
||||||
"go.wit.com/gui"
|
"go.wit.com/gui"
|
||||||
"go.wit.com/lib/gadgets"
|
"go.wit.com/lib/gadgets"
|
||||||
|
"go.wit.com/lib/gui/prep"
|
||||||
"go.wit.com/lib/protobuf/zoopb"
|
"go.wit.com/lib/protobuf/zoopb"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -26,7 +27,7 @@ type mainType struct {
|
||||||
machines *zoopb.Machines // every machine that has reported itself to the zookeeper
|
machines *zoopb.Machines // every machine that has reported itself to the zookeeper
|
||||||
targets map[string]string // what versions the machines should be running
|
targets map[string]string // what versions the machines should be running
|
||||||
upgrade map[string]bool // use this to trigger builds
|
upgrade map[string]bool // use this to trigger builds
|
||||||
myGui *gui.Node // the gui toolkit handle
|
myGui *prep.GuiPrep // the gui toolkit handle
|
||||||
machinesWin *gadgets.GenericWindow // the machines gui window
|
machinesWin *gadgets.GenericWindow // the machines gui window
|
||||||
machinesBox *gui.Node // the machines gui parent box widget
|
machinesBox *gui.Node // the machines gui parent box widget
|
||||||
machinesTB *zoopb.MachinesTable // the machines gui table buffer
|
machinesTB *zoopb.MachinesTable // the machines gui table buffer
|
||||||
|
|
Loading…
Reference in New Issue