diff --git a/Makefile b/Makefile index da02a3e..6c2b827 100644 --- a/Makefile +++ b/Makefile @@ -2,6 +2,14 @@ all: build reset ./gadgetwindow +nocui: build + reset + ./gadgetwindow --gui nocui + +debugger: build + reset + ./gadgetwindow --debugger + build: ifeq ($(GO111MODULE),) echo no. you must use GO111MODULE here diff --git a/args.go b/args.go new file mode 100644 index 0000000..217d0fc --- /dev/null +++ b/args.go @@ -0,0 +1,35 @@ +package main + +/* + this parses the command line arguements + + this enables command line options from other packages like 'gui' and 'log' +*/ + +import ( + "go.wit.com/dev/alexflint/arg" + "go.wit.com/lib/debugger" + "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 { +} + +var NOW *log.LogFlag + +func init() { + arg.MustParse(&args) + full := "go.wit.com/control-panels/dns" + short := "cpdns" + + NOW = log.NewFlag("NOW", true, full, short, "temp debugging stuff") + + if debugger.ArgDebug() { + log.Log(NOW, "INIT() gui debug == true") + } else { + log.Log(NOW, "INIT() gui debug == false") + } +} diff --git a/choices.go b/choices.go index 753e135..7ca1865 100644 --- a/choices.go +++ b/choices.go @@ -29,7 +29,7 @@ func newChoices(parent *gui.Node) *choices { c.grid.NewButton("hello", func() { log.Info("world") }) - c.grid.NewButton("show basic window", func() { + c.grid.NewButton("toggle basic window", func() { basicWindow.Toggle() }) c.grid.NewLabel("a label") @@ -64,7 +64,7 @@ func newChoices(parent *gui.Node) *choices { c.animal.AddText("polar bear") c.place = gadgets.NewBasicEntry(c.grid, "common favorite place") - c.place.Custom = func () { + c.place.Custom = func() { log.Info("now set to:", c.place.String()) if c.place == section1.place { section2.place.SetText(c.place.String()) @@ -75,6 +75,13 @@ func newChoices(parent *gui.Node) *choices { } c.place.SetText("coffee shop") + c.grid.NewButton("enable animals", func() { + c.animal.Enable() + }) + c.grid.NewButton("disable animals", func() { + c.animal.Disable() + }) + return c } diff --git a/main.go b/main.go index c30af42..fa28c37 100644 --- a/main.go +++ b/main.go @@ -23,8 +23,10 @@ var section1 *choices var section2 *choices func main() { + log.SetAll(true) + log.ShowFlags() myGui = gui.New() - myGui.LoadToolkit("andlabs") + // myGui.LoadToolkit("andlabs") // myGui.LoadToolkit("nocui") myGui.Default() @@ -32,6 +34,14 @@ func main() { helloworld() basicWindow = makebasicWindow() + // run the debugger if triggered from the commandline + if debugger.ArgDebug() { + go func() { + log.Sleep(2) + debugger.DebugWindow() + }() + } + // go will sit here until the window exits gui.Watchdog() }