Skip to content

Commit a3d566d

Browse files
authored
Merge pull request #924 from rsteube/command-use-traverse
commamd: invoke traverse directly for completion
2 parents 7f770c0 + 4f68445 commit a3d566d

1 file changed

Lines changed: 3 additions & 10 deletions

File tree

command.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import (
66
"os"
77
"strings"
88

9-
"github.com/rsteube/carapace/internal/uid"
109
"github.com/rsteube/carapace/pkg/style"
1110
"github.com/spf13/cobra"
1211
)
@@ -67,15 +66,9 @@ func addCompletionCommand(cmd *cobra.Command) {
6766
)
6867
Carapace{carapaceCmd}.PositionalAnyCompletion(
6968
ActionCallback(func(c Context) Action {
70-
args := []string{"_carapace", "export", ""}
71-
args = append(args, c.Args[2:]...)
72-
args = append(args, c.Value)
73-
return ActionExecCommand(uid.Executable(), args...)(func(output []byte) Action {
74-
if string(output) == "" {
75-
return ActionValues()
76-
}
77-
return ActionImport(output)
78-
})
69+
cmd.RemoveCommand(carapaceCmd)
70+
action, _ := traverse(cmd, append(c.Args[2:], c.Value))
71+
return action
7972
}),
8073
)
8174

0 commit comments

Comments
 (0)