experiment with go.wit.com/arg here

Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
Jeff Carr 2024-01-03 22:09:15 -06:00
parent 0f28c56854
commit 7cc38284c0
7 changed files with 52 additions and 16 deletions

View File

@ -3,13 +3,12 @@ GOVERSION = $(shell go version | cut -d' ' -f 3)
BUILDTIME = $(shell date -u --iso-8601=seconds) BUILDTIME = $(shell date -u --iso-8601=seconds)
VERSION = $(shell cat resources/VERSION) VERSION = $(shell cat resources/VERSION)
# PATH=/usr/bin:$PATH go version # export GO111MODULE="off"
build: build:
# -git pull -cp ~/go/src/go.wit.com/gui/toolkits/*.so plugins/
-cp ~/go/src/git.wit.org/wit/gui/toolkit/*.so plugins/
go build -v go build -v
./wit-new-machine --gui gocui >/tmp/witgui.log.stderr 2>&1 ./wit-new-machine --debugging
nocui: nocui:
./wit-new-machine --gui-toolkit nocui ./wit-new-machine --gui-toolkit nocui

26
args.go
View File

@ -1,10 +1,28 @@
// This creates a simple hello world window
package main package main
/*
this enables command line options from other packages like 'gui' and 'log'
*/
import ( import (
arg "github.com/alexflint/go-arg" "go.wit.com/log"
"go.wit.com/arg"
"go.wit.com/gui/debugger"
) )
func init() { var argGui ArgsGui
arg.MustParse()
// This struct can be used with the go-arg package
type ArgsGui struct {
Test bool `arg:"--test" help:"enable all logging"`
}
func init() {
arg.MustParse(&argGui)
if debugger.ArgDebug() {
log.Log(true, "INIT() gui debug == true")
} else {
log.Log(true, "INIT() gui debug == false")
}
} }

4
go.mod
View File

@ -4,7 +4,8 @@ go 1.21.4
require ( require (
github.com/alexflint/go-arg v1.4.3 github.com/alexflint/go-arg v1.4.3
go.wit.com/gui v0.9.2 go.wit.com/gui/gui v0.9.8
go.wit.com/log v0.0.0-20240102010317-907893ba7b4b
golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a golang.org/x/mobile v0.0.0-20231127183840-76ac6878050a
) )
@ -13,6 +14,7 @@ require (
github.com/sourcegraph/conc v0.3.0 // indirect github.com/sourcegraph/conc v0.3.0 // indirect
go.uber.org/atomic v1.7.0 // indirect go.uber.org/atomic v1.7.0 // indirect
go.uber.org/multierr v1.9.0 // indirect go.uber.org/multierr v1.9.0 // indirect
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 // indirect
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 // indirect
golang.org/x/image v0.14.0 // indirect golang.org/x/image v0.14.0 // indirect
golang.org/x/sys v0.15.0 // indirect golang.org/x/sys v0.15.0 // indirect

8
go.sum
View File

@ -19,8 +19,12 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI= go.uber.org/multierr v1.9.0 h1:7fIwc/ZtS0q++VgcfqFDxSBZVv/Xo49/SYnDFupUwlI=
go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ= go.uber.org/multierr v1.9.0/go.mod h1:X2jQV1h+kxSjClGpnseKVIxpmcjrj7MNnI0bnlfKTVQ=
go.wit.com/gui v0.9.2 h1:QHMYdwpV6MzKwmFUMGevKUDn2a6GAqHN2Ltx8V3HufI= go.wit.com/gui/gui v0.9.8 h1:oMqM4sfucMnZxh9e2F0DKxNTuVxl2JZGXcuTRnGW+xI=
go.wit.com/gui v0.9.2/go.mod h1:asRXEYKmdjhtg1yiBi5A8YEY2YG4lWPS0gvNz4NXGDE= go.wit.com/gui/gui v0.9.8/go.mod h1:H2+uDT6qoQ8UkV6QUNIC1MQsgy6/aAop0zWBHnwACso=
go.wit.com/log v0.0.0-20240102010317-907893ba7b4b h1:YqDB6AChqjmt5jYN4F79UrjIDoUt58pfCgXJwp+G2wg=
go.wit.com/log v0.0.0-20240102010317-907893ba7b4b/go.mod h1:GmsggfsKrqdZdAj26fEOlcTz6qEIazbV33uyuuktvB8=
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9 h1:UEX2EzLQPzLTfy/kUFQD7OXtvKn8wk/+jpDOkbl4ff4=
go.wit.com/spew v0.0.0-20240101141411-c7b8e91573c9/go.mod h1:qBpgJXThMMT15vym7/E4Ur9y8oOo2nP7t2RP52QHUNw=
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 h1:3AGKexOYqL+ztdWdkB1bDwXgPBuTS/S8A4WzuTvJ8Cg= golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63 h1:3AGKexOYqL+ztdWdkB1bDwXgPBuTS/S8A4WzuTvJ8Cg=
golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0= golang.org/x/exp/shiny v0.0.0-20230817173708-d852ddb80c63/go.mod h1:UH99kUObWAZkDnWqppdQe5ZhPYESUw8I0zVV1uWBR+0=
golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4= golang.org/x/image v0.14.0 h1:tNgSxAFe3jC4uYqvZdTr84SZoM1KfwdC9SKIFrLjFn4=

9
gui.go
View File

@ -1,10 +1,11 @@
package main package main
import ( import (
"log"
"time" "time"
"os" "os"
"io/ioutil" "io/ioutil"
"go.wit.com/gui" "go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/debugger"
) )
var myGui *gui.Node var myGui *gui.Node
@ -94,6 +95,10 @@ func drawWindow() {
os.Exit(0) os.Exit(0)
}) })
rn.NewButton("DebugWindow()", func () {
debugger.DebugWindow(myGui)
})
rn.NewLabel("Not yet working stuff") rn.NewLabel("Not yet working stuff")
rn.NewButton("resolv.conf", func () { rn.NewButton("resolv.conf", func () {

12
main.go
View File

@ -3,12 +3,14 @@ package main
import ( import (
"os" "os"
"os/exec" "os/exec"
"log"
"embed" "embed"
"strings" "strings"
"bytes" "bytes"
"go.wit.com/gui" "go.wit.com/arg"
"go.wit.com/log"
"go.wit.com/gui/gui"
"go.wit.com/gui/debugger"
) )
var GITCOMMIT string // this is passed in as an ldflag var GITCOMMIT string // this is passed in as an ldflag
@ -47,11 +49,17 @@ func doCmd(str string) {
func main() { func main() {
log.Println("starting my Control Panel") log.Println("starting my Control Panel")
arg.MustParse()
// myGui = gui.New().InitEmbed(resToolkit) // myGui = gui.New().InitEmbed(resToolkit)
myGui = gui.New().Default() myGui = gui.New().Default()
drawWindow() drawWindow()
if debugger.ArgDebug() {
log.Sleep(2)
debugger.DebugWindow(myGui)
}
gui.Watchdog() gui.Watchdog()
} }

View File

@ -1,7 +1,7 @@
package main package main
import ( import (
"go.wit.com/gui" "go.wit.com/gui/gui"
) )
// setup a new machine // setup a new machine