summaryrefslogtreecommitdiff
path: root/complete.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-26 10:49:12 -0500
committerJeff Carr <[email protected]>2025-10-26 10:49:12 -0500
commitd22db5dabfc6f8330b38adedd0528192ae2d47d8 (patch)
tree725c410000f83009b1ce6a6d2da6712db082eb9c /complete.go
parent2a466a788a0f78dddce2ca544db6e34f0b8e2f12 (diff)
parent51027a1b04b3da1a81d617d16a07ac1242d90a81 (diff)
Merge branch 'jcarr' into develHEADmasterdevel
Diffstat (limited to 'complete.go')
-rw-r--r--complete.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/complete.go b/complete.go
new file mode 100644
index 0000000..b7c7a47
--- /dev/null
+++ b/complete.go
@@ -0,0 +1,42 @@
+// 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 = "mirrors" // todo: get this from $0
+
+func (args) MustParse() error {
+ me.pp = arg.MustParse(&argv)
+ return nil
+}
+
+// sends the strings to bash or zsh that will be your options
+func (a args) DoAutoComplete() error {
+ if argvpb.PB.GetCmd() == "" {
+ matches := []string{"--dry-run", "--force", "incoming", "walk", "list", "everything", "verify", "newest", "--create", "--verbose", "release"}
+ fmt.Fprintf(argvpb.Stdout, " %s", strings.Join(matches, " "))
+ return nil
+ }
+ var err error
+ if me.pp == nil {
+ me.pp, err = arg.ParseFlagsArgv(&argv)
+ if err != nil {
+ return err
+ }
+ }
+ err = me.pp.WriteHelpForAutocomplete(argvpb.PB.Partial, argvpb.PB.Real...)
+ return err
+}