Compare commits

...

7 Commits

Author SHA1 Message Date
Jeff Carr 7fc97cd1e9 defualt build is quiet 2024-11-16 04:58:45 -06:00
Jeff Carr 0a38ebfd47 fix build 2024-11-16 00:08:04 -06:00
Jeff Carr af99bd179c include toolkit resources in binary 2024-11-07 16:54:16 -06:00
Jeff Carr 3133bb0801 english 2024-11-07 13:50:28 -06:00
Jeff Carr 1b7db666f1 update argv code
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-11-07 13:03:42 -06:00
Jeff Carr d6f9401f61 also always build here 2024-02-16 11:40:19 -06:00
Jeff Carr 66694c1a09 make a simple way to enable the debugger
Signed-off-by: Jeff Carr <jcarr@wit.com>
2024-02-12 08:27:39 -06:00
4 changed files with 104 additions and 11 deletions

View File

@ -1,15 +1,40 @@
all:
go build -v -x
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
all: build
./helloworld
push:
git add --all
git commit -a
git push
build:
GO111MODULE=off go build \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
verbose:
GO111MODULE=off go build -v -x -work \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
install:
GO111MODULE=off go install \
-ldflags "-X main.VERSION=${VERSION} -X main.BUILDTIME=${BUILDTIME} -X gui.GUIVERSION=${VERSION}"
clean:
-rm -f gadgetwindow
-rm resources/*.so
touch resources/blank.so
# embed the toolkit plugins in the binary
embed:
-rm resources/*.so
touch resources/blank.so
-cp -a ~/go/src/go.wit.com/toolkits/*.so resources/
gocui:
./helloworld --gui gocui
goimports:
goimports -w *.go
redomod:
rm -f go.*
goimports -w *.go
GO111MODULE= go mod init
GO111MODULE= go mod tidy

39
argv.go Normal file
View File

@ -0,0 +1,39 @@
package main
import (
"os"
"github.com/alexflint/go-arg"
)
/*
this parses the command line arguements
this enables command line options from other packages like 'gui' and 'log'
*/
var argv args
type args struct {
Demo string `arg:"positional" help:"this is just a demo"`
}
func (a args) Description() string {
return `
This helloworld example demonstrates the 'gui' plugin toolkits
`
}
func init() {
pp := arg.MustParse(&argv)
// for very new users or users unfamilar with the command line, this may help them
if argv.Demo == "version" || argv.Demo == "help" || argv.Demo == "?" {
pp.WriteHelp(os.Stdout)
os.Exit(0)
}
}
func (args) Version() string {
return "helloworld " + VERSION
}

20
debugger.go Normal file
View File

@ -0,0 +1,20 @@
package main
/*
enables GUI options and the debugger in your application
*/
import (
"go.wit.com/lib/debugger"
"go.wit.com/log"
)
func init() {
if debugger.ArgDebug() {
log.Info("cmd line --debugger == true")
go func() {
log.Sleep(2)
debugger.DebugWindow()
}()
}
}

17
main.go
View File

@ -1,20 +1,30 @@
// This creates a simple helloworld window
package main
import (
"embed"
"go.wit.com/gui"
"go.wit.com/log"
)
// sent via -ldflags
var VERSION string
// This is the beginning of our binary tree of widgets
var myGui *gui.Node
//go:embed resources/*
var resources embed.FS
func main() {
myGui = gui.New().Default()
myGui = gui.New()
myGui.InitEmbed(resources)
myGui.Default()
helloworld()
// go will sit here until the window exits
// intermittently, it will show toolkit statistics
gui.Watchdog()
}
@ -43,11 +53,10 @@ func helloworld() {
color.AddText("Cyan")
color.AddText("Magenta")
color.AddText("Yellow")
color.Custom = func () {
color.Custom = func() {
log.Info("color is now", color.String())
}
check := grid.NewCheckbox("Checkers").SetProgName("CHECKERS")
check.Custom = func() {
log.Info("Checkers is now", check.Bool())