summaryrefslogtreecommitdiff
path: root/complete.go
diff options
context:
space:
mode:
Diffstat (limited to 'complete.go')
-rw-r--r--complete.go43
1 files changed, 43 insertions, 0 deletions
diff --git a/complete.go b/complete.go
new file mode 100644
index 0000000..ef2815e
--- /dev/null
+++ b/complete.go
@@ -0,0 +1,43 @@
+// Copyright 2017-2025 WIT.COM Inc. All rights reserved.
+// Use of this source code is governed by the GPL 3.0
+
+package main
+
+import (
+ "fmt"
+ "strings"
+
+ "go.wit.com/dev/alexflint/arg"
+ "go.wit.com/lib/protobuf/argvpb"
+)
+
+// sent via -ldflags
+var VERSION string
+var BUILDTIME string
+
+// used for shell auto completion
+var APPNAME string = "go-gui-toolkits" // todo: get this from $0
+
+// sends the strings to bash or zsh that will be your options
+func (a args) DoAutoComplete() error {
+ var err error
+ me.pp, err = arg.ParseFlagsArgv(&argv)
+ if err != nil {
+ fmt.Fprintf(argvpb.Stddbg, "go-args parseFlagsArgv(%v) finished autocomplete\n", err)
+ }
+ return err
+}
+
+func (args) MustParse() error {
+ me.pp = arg.MustParseArgv(&argv)
+ return nil
+}
+
+func (args) Match() bool {
+ if argvpb.PB.GetCmd() == "" {
+ matches := []string{"all", "--verbose", "--version"}
+ fmt.Fprintf(argvpb.Stdout, " %s", strings.Join(matches, " "))
+ return true
+ }
+ return false
+}