summaryrefslogtreecommitdiff
path: root/complete.go
diff options
context:
space:
mode:
authorJeff Carr <[email protected]>2025-10-26 09:34:33 -0500
committerJeff Carr <[email protected]>2025-10-26 09:34:33 -0500
commit3c25d4a6aa196b9b685d6c27dfaf6a4998b24598 (patch)
tree336698b5e4a1557639cbfcba9528194bbf34c20a /complete.go
parent5314952e14cedbb1d5827f66827c16a58ae05096 (diff)
new argvv0.7.115
Diffstat (limited to 'complete.go')
-rw-r--r--complete.go59
1 files changed, 59 insertions, 0 deletions
diff --git a/complete.go b/complete.go
new file mode 100644
index 0000000..22b7a63
--- /dev/null
+++ b/complete.go
@@ -0,0 +1,59 @@
+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
+
+var APPNAME string = "go-clone"
+
+func (args) Version() string {
+ return "go-clone " + VERSION + " Built on " + BUILDTIME
+}
+
+func (args) Buildtime() (string, string) {
+ return BUILDTIME, VERSION
+}
+
+func (a args) Description() string {
+ return `
+git clone go repositories recursively
+
+Examples:
+ go-clone go.wit.com/apps/go-clone # 'git clone' go-clone
+`
+}
+
+func (args) Appname() string {
+ return APPNAME
+}
+
+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", "--non-recursive", "--work", "--version"}
+ 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
+}