From d68c81c1add8b09aed8b8a19c6b61610a9ff8605 Mon Sep 17 00:00:00 2001 From: Jeff Carr Date: Sat, 18 Oct 2025 03:21:39 -0500 Subject: switching to the new 'argv' --- argv.go | 28 ++++++++++++++++++++++++---- main.go | 19 ++----------------- structs.go | 8 ++++---- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/argv.go b/argv.go index 59ad7ff..83e333a 100644 --- a/argv.go +++ b/argv.go @@ -1,5 +1,10 @@ package main +import ( + "go.wit.com/dev/alexflint/arg" + "go.wit.com/gui" +) + /* this parses the command line arguements this enables command line options from other packages like 'gui' and 'log' @@ -7,16 +12,31 @@ package main var argv args +var APPNAME string = "basicwindow" + +// sent via -ldflags +var VERSION string +var BUILDTIME string + +// define your command line arguements here type args struct { Demo string `arg:"positional" help:"this is just a demo"` } +func (args) InitArgv() (string, string, string) { + // "basicwindow", "2025/10/18", "v0.2.0" + return APPNAME, BUILDTIME, VERSION +} + +func (args) InitGui() error { + // panic("got here") + arg.Register(&gui.ArgvGui) + // me.myGui = gui.New() + return nil +} + func (a args) Description() string { return ` This basicwindow example demonstrates multiple windows ` } - -func (args) Version() string { - return "basicwindow " + VERSION -} diff --git a/main.go b/main.go index 7af7d4a..c92965e 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,12 @@ package main import ( - "os" - - "go.wit.com/dev/alexflint/arg" "go.wit.com/gui" "go.wit.com/lib/gadgets" - "go.wit.com/lib/gui/prep" + "go.wit.com/lib/protobuf/argvpb" "go.wit.com/log" ) -// sent via -ldflags -var VERSION string - // this is the primary window. If you close it, the program will exit var mainWindow *gui.Node @@ -27,16 +21,7 @@ var colors *gui.Node func main() { me := new(mainType) - me.myGui = prep.Gui() // prepares the GUI package for go-args - me.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 == "?" { - me.pp.WriteHelp(os.Stdout) - os.Exit(0) - } - - me.myGui.Start() // loads the GUI toolkit (GO Plugins) + me.argv = argvpb.Autocomplete(&argv) // adds shell auto complete to go-args helloworld() basicWindow = makebasicWindow() diff --git a/structs.go b/structs.go index 6251719..a4a2c4e 100644 --- a/structs.go +++ b/structs.go @@ -4,14 +4,14 @@ package main import ( - "go.wit.com/dev/alexflint/arg" - "go.wit.com/lib/gui/prep" + "go.wit.com/gui" + "go.wit.com/lib/protobuf/argvpb" ) var me *mainType // this app's variables type mainType struct { - pp *arg.Parser // for parsing the command line args. Yay to alexf lint! - myGui *prep.GuiPrep // the gui toolkit handle + argv *argvpb.Argv // shell autocomplete + myGui *gui.Node // the gui toolkit handle } -- cgit v1.2.3