summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-18 10:23:24 -0500
committerJeff Carr <[email protected]>2025-10-18 10:23:24 -0500
commit317ee925ef78d5eac752232dd78bd24385141bf6 (patch)
tree475ad026ad4c19c1290f504c464a6db96b719848
parentc5b9bef5ed74c4180da6e6425d1bfd79f3a57f5c (diff)
lots more is working
-rw-r--r--argv.custom.go19
-rw-r--r--argv.template.go13
2 files changed, 31 insertions, 1 deletions
diff --git a/argv.custom.go b/argv.custom.go
index 066d80a..1e8abac 100644
--- a/argv.custom.go
+++ b/argv.custom.go
@@ -1,5 +1,11 @@
package main
+import (
+ "os"
+
+ "go.wit.com/lib/protobuf/argvpb"
+)
+
// this is where to customize argv for your application
var APPNAME string = "basicwindow"
@@ -13,3 +19,16 @@ func (a args) Description() string {
This basicwindow example demonstrates multiple windows
`
}
+
+// sends the strings to bash or zsh that will be your options
+func (a args) SendCompletionStrings(pb *argvpb.Argv) {
+ if pb.Cmd == "" {
+ // these are base autocomplete strings
+ matches := []string{"--bash", "--version", "demo", "gui"}
+ pb.SendStrings(matches)
+ } else {
+ // autogenerate the strings for the subcommand using github.com/alexflint/go-arg
+ pb.GenerateSubCommandStrings(pb.Goargs...)
+ }
+ os.Exit(0)
+}
diff --git a/argv.template.go b/argv.template.go
index f6cd250..8be4948 100644
--- a/argv.template.go
+++ b/argv.template.go
@@ -36,6 +36,17 @@ func (args) WriteHelpForAutocomplete(part string, subcmd ...string) error {
return me.pp.WriteHelpForAutocomplete(os.Stderr, os.Stdout, part, subcmd...)
}
+func (args) WriteHelpForAutocompleteDebug(part string, subcmd ...string) error {
+ f, _ := os.OpenFile("/tmp/argv.junk", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
+ return me.pp.WriteHelpForAutocomplete(f, os.Stdout, part, subcmd...)
+}
+
+// add this funcgion: this will print the help
+func (args) WriteHelp() error {
+ me.pp.WriteHelp(os.Stderr)
+ return nil
+}
+
func (args) InitGui() error {
// panic("got here")
arg.Register(&gui.ArgvGui)
@@ -47,7 +58,7 @@ func (args) InitGui() error {
func (args) Exit() {
gui.UnloadToolkits()
if me.argv.Verbose() {
- log.Info("argv.Exit() called", APPNAME + ".Exit()")
+ log.Info("argv.Exit() called", APPNAME+".Exit()")
}
}