diff options
| -rw-r--r-- | complete.go | 40 |
1 files changed, 11 insertions, 29 deletions
diff --git a/complete.go b/complete.go index a1968bf..6189b1c 100644 --- a/complete.go +++ b/complete.go @@ -80,51 +80,33 @@ func (args) Examples() string { return out } -func (args) Match() bool { - if argvpb.PB.IsMatch("cache") { - matches, _ := matchCacheFiles() - fmt.Fprintf(argvpb.Stdout, "%s", matches) - return true - } - - if argvpb.PB.IsMatch("mode.--config") { - matches, _ := matchModeDirs() - fmt.Fprintf(argvpb.Stdout, "%s", matches) - return true - } - - if argvpb.PB.IsMatch("mode") { - matches := []string{"jwc", "false"} - fmt.Fprintf(argvpb.Stdout, "%s", " "+strings.Join(matches, " ")) - return true - } - return false -} - // 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) - // counter intuitive. return nil on err for now - return nil } + return err +} + +func (args) Match() bool { if argvpb.PB.IsMatch("cache") { matches, _ := matchCacheFiles() fmt.Fprintf(argvpb.Stdout, "%s", matches) - return nil + return true } + if argvpb.PB.IsMatch("mode.--config") { matches, _ := matchModeDirs() fmt.Fprintf(argvpb.Stdout, "%s", matches) - return nil + return true } + if argvpb.PB.IsMatch("mode") { - err = me.pp.WriteHelpForAutocomplete("", "mode") matches := []string{"jwc", "false"} fmt.Fprintf(argvpb.Stdout, "%s", " "+strings.Join(matches, " ")) - return nil + return true } if argvpb.PB.GetCmd() == "" { // these are base autocomplete strings @@ -132,9 +114,9 @@ func (a args) DoAutoComplete() error { matches = append(matches, "show", "add", "fixer", "dev", "verify", "mode", "gui", "whatchanged") matches = append(matches, "--version", "--force", "--all", "--verbose", "--help") fmt.Fprintf(argvpb.Stdout, "%s", strings.Join(matches, " ")) - return nil + return true } - return err + return false } func matchModeDirs() (string, error) { |
