Skip to content

Commit

Permalink
commamd: invoke traverse directly for completion
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Oct 2, 2023
1 parent 0e0f241 commit 4f68445
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions command.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"strings"

"github.com/rsteube/carapace/internal/uid"
"github.com/rsteube/carapace/pkg/style"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -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
}),
)

Expand Down

0 comments on commit 4f68445

Please sign in to comment.