diff --git a/example/cmd/compat.go b/example/cmd/compat.go index c8cc24269..837dd5834 100644 --- a/example/cmd/compat.go +++ b/example/cmd/compat.go @@ -25,6 +25,8 @@ func init() { compatCmd.Flags().String("keeporder", "", "ShellCompDirectiveKeepOrder") compatCmd.Flags().String("default", "", "ShellCompDirectiveDefault") + compatCmd.Flags().String("unset", "", "no completions defined") + rootCmd.AddCommand(compatCmd) compatCmd.RegisterFlagCompletionFunc("error", func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) { diff --git a/example/cmd/compat_test.go b/example/cmd/compat_test.go index 07bf64770..bf0777b68 100644 --- a/example/cmd/compat_test.go +++ b/example/cmd/compat_test.go @@ -76,5 +76,9 @@ func TestCompat(t *testing.T) { Tag("files"). StyleF(style.ForPath). Usage("ShellCompDirectiveDefault")) + + s.Run("compat", "--unset", ""). + Expect(carapace.ActionValues(). + Usage("no completions defined")) }) } diff --git a/storage.go b/storage.go index 3f022c193..a4d3efc58 100644 --- a/storage.go +++ b/storage.go @@ -60,8 +60,9 @@ func (s _storage) bridge(cmd *cobra.Command) { defer bridgeMutex.Unlock() if !entry.initialized { - registerValidArgsFunction(cmd) - registerFlagCompletion(cmd) + // TODO only if completion is defined in carapace + // registerValidArgsFunction(cmd) + // registerFlagCompletion(cmd) entry.initialized = true }