diff options
| -rw-r--r-- | argv.go | 28 | ||||
| -rw-r--r-- | main.go | 19 | ||||
| -rw-r--r-- | structs.go | 8 |
3 files changed, 30 insertions, 25 deletions
@@ -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 -} @@ -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() @@ -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 } |
