diff options
| author | Jeff Carr <[email protected]> | 2024-01-27 09:04:43 -0600 |
|---|---|---|
| committer | Jeff Carr <[email protected]> | 2024-01-27 09:04:43 -0600 |
| commit | a72024107be0c01375508d7ac732fc29a4bad8e7 (patch) | |
| tree | 47bbc001af74c3ff89bd9919306fb881b51daf8d | |
| parent | 0bdabc5747163859ddf88e0ea0a4b1712a658bb9 (diff) | |
nocui works
Signed-off-by: Jeff Carr <[email protected]>
| -rw-r--r-- | Makefile | 8 | ||||
| -rw-r--r-- | args.go | 35 | ||||
| -rw-r--r-- | choices.go | 11 | ||||
| -rw-r--r-- | main.go | 12 |
4 files changed, 63 insertions, 3 deletions
@@ -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 @@ -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") + } +} @@ -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 } @@ -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() } |
