Skip to content

Commit

Permalink
Merge pull request #951 from rsteube/actioncobracomplete-fix-directive
Browse files Browse the repository at this point in the history
ActionCobraComplete: fix directive check
  • Loading branch information
rsteube authored Feb 23, 2022
2 parents 1b4cb49 + 30263ae commit 775bab9
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
5 changes: 4 additions & 1 deletion cmd/carapace/cmd/bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,10 @@ func createCmd(command string, engine string) *cobra.Command {
cmd := &cobra.Command{
Use: command,
DisableFlagParsing: true,
Run: func(cmd *cobra.Command, args []string) {},
CompletionOptions: cobra.CompletionOptions{
DisableDefaultCmd: true,
},
Run: func(cmd *cobra.Command, args []string) {},
}

carapace.Gen(cmd).PositionalAnyCompletion(
Expand Down
6 changes: 5 additions & 1 deletion completers/git_completer/cmd/difftool.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/os"
"github.com/rsteube/carapace-bin/pkg/actions/tools/git"
"github.com/spf13/cobra"
)
Expand All @@ -27,7 +28,10 @@ func init() {
rootCmd.AddCommand(difftoolCmd)

carapace.Gen(difftoolCmd).FlagCompletion(carapace.ActionMap{
"tool": carapace.ActionFiles(),
"tool": carapace.Batch(
os.ActionPathExecutables(),
carapace.ActionFiles(),
).ToA(),
})

carapace.Gen(difftoolCmd).PositionalCompletion(
Expand Down
2 changes: 1 addition & 1 deletion pkg/actions/bridge/cobra.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func ActionCobraComplete(cmd string) carapace.Action {
type compDirective int

func (d compDirective) matches(cobraDirective cobra.ShellCompDirective) bool {
return d&compDirective(cobraDirective) == d
return d&compDirective(cobraDirective) != 0
}

func readDirective(lines []string) (compDirective, error) {
Expand Down

0 comments on commit 775bab9

Please sign in to comment.