From 4f68445e7a5a9886679b9d735ebe38db9765b2d0 Mon Sep 17 00:00:00 2001 From: rsteube Date: Mon, 2 Oct 2023 12:39:41 +0200 Subject: [PATCH] commamd: invoke traverse directly for completion --- command.go | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/command.go b/command.go index ba89e5eed..f58937f6e 100644 --- a/command.go +++ b/command.go @@ -6,7 +6,6 @@ import ( "os" "strings" - "github.com/rsteube/carapace/internal/uid" "github.com/rsteube/carapace/pkg/style" "github.com/spf13/cobra" ) @@ -67,15 +66,9 @@ func addCompletionCommand(cmd *cobra.Command) { ) Carapace{carapaceCmd}.PositionalAnyCompletion( ActionCallback(func(c Context) Action { - args := []string{"_carapace", "export", ""} - args = append(args, c.Args[2:]...) - args = append(args, c.Value) - return ActionExecCommand(uid.Executable(), args...)(func(output []byte) Action { - if string(output) == "" { - return ActionValues() - } - return ActionImport(output) - }) + cmd.RemoveCommand(carapaceCmd) + action, _ := traverse(cmd, append(c.Args[2:], c.Value)) + return action }), )