summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--argv.custom.go15
-rw-r--r--argv.go42
-rw-r--r--argv.struct.go7
-rw-r--r--argv.template.go50
-rw-r--r--structs.go6
6 files changed, 79 insertions, 45 deletions
diff --git a/Makefile b/Makefile
index d8766e2..e45722a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,7 +1,9 @@
VERSION = $(shell git describe --tags)
BUILDTIME = $(shell date +%Y.%m.%d)
-all: build gocui
+all: install
+ basicwindow --help
+
build: goimports vet
GO111MODULE=off go build -v -x \
diff --git a/argv.custom.go b/argv.custom.go
new file mode 100644
index 0000000..066d80a
--- /dev/null
+++ b/argv.custom.go
@@ -0,0 +1,15 @@
+package main
+
+// this is where to customize argv for your application
+
+var APPNAME string = "basicwindow"
+
+// sent via -ldflags
+var VERSION string
+var BUILDTIME string
+
+func (a args) Description() string {
+ return `
+This basicwindow example demonstrates multiple windows
+`
+}
diff --git a/argv.go b/argv.go
deleted file mode 100644
index 83e333a..0000000
--- a/argv.go
+++ /dev/null
@@ -1,42 +0,0 @@
-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'
-*/
-
-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
-`
-}
diff --git a/argv.struct.go b/argv.struct.go
new file mode 100644
index 0000000..36c5c2d
--- /dev/null
+++ b/argv.struct.go
@@ -0,0 +1,7 @@
+package main
+
+var argv args
+
+type args struct {
+ Demo string `arg:"positional" help:"this is just a demo"`
+}
diff --git a/argv.template.go b/argv.template.go
new file mode 100644
index 0000000..e27de59
--- /dev/null
+++ b/argv.template.go
@@ -0,0 +1,50 @@
+package main
+
+// these are stubbed in functions needed
+// just copy this file from another working app for now
+// you shouldn't need to change anything here
+// TODO: clean this up in argv
+
+import (
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/gui"
+)
+
+func (args) InitArgv() (string, string, string) {
+ return APPNAME, BUILDTIME, VERSION
+}
+
+func (args) InitGui() error {
+ // panic("got here")
+ arg.Register(&gui.ArgvGui)
+ // me.myGui = gui.New()
+ return nil
+}
+
+func (args) Help() string {
+ return "got app help"
+}
+
+func (args) MustParse() error {
+ me.pp = arg.MustParse(&argv)
+ return nil
+}
+
+func (args) ParseFlags(flags []string, dest string) {
+}
+
+/*
+argv.Print.go: me.pp.WriteHelp(os.Stdout)
+argv.SendStrings.go: me.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, partial, cmd...)
+argv.SendStrings.go: // me.pp.GetUsageForSubcommand(os.Stdout, os.Stderr, partial, cmd)
+argv.SendStrings.go: // me.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd)
+argv.SendStrings.go: me.pp.WriteHelpForAutocomplete(f, os.Stdout, partial, cmd...)
+argv.SendStrings.go: // me.pp.GetUsageForSubcommand(os.Stdout, nil, partial, cmd)
+theMagicOfAutocomplete.go: me.pp = arg.MustParse(dest)
+theMagicOfAutocomplete.go: me.pp, err = arg.ParseFlags(flags, dest)
+theMagicOfAutocomplete.go: if me.pp == nil {
+theMagicOfAutocomplete.go: me.pb.Debugf("DEBUG: me.pp == nil after ParseFlags()")
+theMagicOfAutocomplete.go: // me.pb.Debugf("DEBUG: me.pp is ok after ParseFlags()")
+theMagicOfAutocomplete.go: me.pp.WriteHelp(os.Stderr)
+theMagicOfAutocomplete.go: me.pp.WriteHelpForSubcommand(os.Stderr, me.pb.Cmd)
+*/
diff --git a/structs.go b/structs.go
index a4a2c4e..7805d8d 100644
--- a/structs.go
+++ b/structs.go
@@ -5,6 +5,7 @@ package main
import (
"go.wit.com/gui"
+ "go.wit.com/dev/alexflint/arg"
"go.wit.com/lib/protobuf/argvpb"
)
@@ -12,6 +13,7 @@ var me *mainType
// this app's variables
type mainType struct {
- argv *argvpb.Argv // shell autocomplete
- myGui *gui.Node // the gui toolkit handle
+ argv *argvpb.Argv // shell autocomplete
+ pp *arg.Parser // the go-arg parser of the command line
+ gui *gui.Node // the gui toolkit handle
}