Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed Sep 25, 2023
1 parent ae449ca commit 8d045bf
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example/cmd/compat.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,8 @@ func init() {
compatCmd.RegisterFlagCompletionFunc("nofilecomp", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return nil, cobra.ShellCompDirectiveNoFileComp
})

compatCmd.RegisterFlagCompletionFunc("filterfileext", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
return []string{"mod", "sum"}, cobra.ShellCompDirectiveFilterFileExt
})
}
16 changes: 16 additions & 0 deletions example/cmd/compat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@ import (

"github.com/rsteube/carapace"
"github.com/rsteube/carapace/pkg/sandbox"
"github.com/rsteube/carapace/pkg/style"
)

func TestCompat(t *testing.T) {
sandbox.Package(t, "github.com/rsteube/carapace/example")(func(s *sandbox.Sandbox) {
s.Files(
"go.mod", "",
"go.sum", "",
"README.md", "",
)

s.Run("compat", "--error", "").
Expect(carapace.ActionMessage("an error occured").
Usage("ShellCompDirectiveError"))
Expand All @@ -23,5 +30,14 @@ func TestCompat(t *testing.T) {
s.Run("compat", "--nofilecomp", "").
Expect(carapace.ActionValues().
Usage("ShellCompDirectiveNoFileComp"))

s.Run("compat", "--filterfileext", "").
Expect(carapace.ActionValues(
"go.mod",
"go.sum",
).NoSpace('/').
Tag("files").
StyleF(style.ForPath).
Usage("ShellCompDirectiveFilterFileExt"))
})
}

0 comments on commit 8d045bf

Please sign in to comment.