Skip to content

Commit

Permalink
Merge pull request #924 from rsteube/command-use-traverse
Browse files Browse the repository at this point in the history
commamd: invoke traverse directly for completion
  • Loading branch information
rsteube authored Oct 2, 2023
2 parents 7f770c0 + 4f68445 commit a3d566d
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 a3d566d

Please sign in to comment.