summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--argv.custom.go27
1 files changed, 17 insertions, 10 deletions
diff --git a/argv.custom.go b/argv.custom.go
index 9525e82..0184c92 100644
--- a/argv.custom.go
+++ b/argv.custom.go
@@ -5,9 +5,9 @@ package main
import (
"fmt"
- "os"
"strings"
+ "go.wit.com/dev/alexflint/arg"
"go.wit.com/gui"
"go.wit.com/lib/debugger"
"go.wit.com/lib/fhelp"
@@ -86,12 +86,12 @@ func (c CleanCmd) Match(partial string) []string {
// sends the strings to bash or zsh that will be your options
func (a args) SendCompletionStrings(pb *argvpb.Argv) {
if pb.IsMatch("mode.config") {
- pb.SendStrings([]string{"mine", "favorites"})
- os.Exit(0)
+ matches := []string{"mine", "favorites"}
+ fmt.Fprintf(argvpb.Stdout, strings.Join(matches, " "))
}
if pb.IsMatch("mode") {
- pb.SendStrings([]string{"once", "many", "mine", "favorites"})
- os.Exit(0)
+ matches := []string{"once", "many", "mine", "favorites"}
+ fmt.Fprintf(argvpb.Stdout, strings.Join(matches, " "))
}
if pb.GetCmd() == "" {
// these are base autocomplete strings
@@ -99,10 +99,17 @@ func (a args) SendCompletionStrings(pb *argvpb.Argv) {
matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui", "whatchanged")
matches = append(matches, "--version", "--force", "--all")
fmt.Fprintf(argvpb.Stdout, strings.Join(matches, " "))
- // pb.SendStrings(matches)
- } else {
- // autogenerate the strings for the subcommand using github.com/alexflint/go-arg
- pb.GenerateSubCommandStrings(pb.Real...)
+ return
+ }
+ var err error
+ if me.pp == nil {
+ me.pp, err = arg.ParseFlagsArgv(&argv)
+ fmt.Fprintf(argvpb.Stderr, "returned from parseFlagsArgv(%v)\n", err)
}
- // os.Exit(0)
+ // matches := []string{"show", "repos"}
+ // err = me.pp.WriteHelpForAutocomplete(argvpb.PB.Partial, matches...)
+ // fmt.Fprintf(argvpb.Stderr, "returned from WriteHelpForAutocomplete() matches(%v)\n", matches)
+ err = me.pp.WriteHelpForAutocomplete(argvpb.PB.Partial, argvpb.PB.Real...)
+ fmt.Fprintf(argvpb.Stderr, "returned from WriteHelpForAutocomplete() pb.Real(%v)\n", pb.Real)
+ fmt.Fprintf(argvpb.Stderr, "returned from WriteHelpForAutocomplete(%v)\n", err)
}