Skip to content

Commit

Permalink
xargs: use bridge.ActionCarapaceBin
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 24, 2022
1 parent da64eb5 commit bc80ddc
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions completers/xargs_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"path/filepath"

"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/bridge"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/spf13/cobra"
)
Expand Down Expand Up @@ -64,16 +65,8 @@ func init() {
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
// TODO this does not yet work for flags as rootCmd flag completion has precendence
executable := filepath.Base(c.Args[0])
args := []string{executable, "export", ""}
args = append(args, c.Args[1:]...)
args = append(args, c.CallbackValue)
return carapace.ActionExecCommand("carapace", args...)(func(output []byte) carapace.Action {
// TODO carapace needs exit code on error
if string(output) == "" {
return carapace.ActionValues()
}
return carapace.ActionImport(output)
})
c.Args = c.Args[1:]
return bridge.ActionCarapaceBin(executable).Invoke(c).ToA()
}),
)
}

0 comments on commit bc80ddc

Please sign in to comment.