diff --git a/cmd/carapace/cmd/action/completer.go b/cmd/carapace/cmd/action/completer.go index 8cd0b759f7..5e1cdad4b6 100644 --- a/cmd/carapace/cmd/action/completer.go +++ b/cmd/carapace/cmd/action/completer.go @@ -9,7 +9,7 @@ import ( func ActionCompleters() carapace.Action { return carapace.ActionCallback(func(c carapace.Context) carapace.Action { - return carapace.ActionExecCommand("carapace", "--list")(func(output []byte) carapace.Action { + return carapace.ActionExecCommand("carapace", "--list", "--format", "json")(func(output []byte) carapace.Action { var completers []struct { Name string Description string diff --git a/cmd/carapace/cmd/list.go b/cmd/carapace/cmd/list.go index 838753e950..c79eadca47 100644 --- a/cmd/carapace/cmd/list.go +++ b/cmd/carapace/cmd/list.go @@ -15,11 +15,12 @@ var listCmd = &cobra.Command{ Use: "--list", Short: "", Run: func(cmd *cobra.Command, args []string) { - // case "json": - printCompletersJson() - // default: - // printCompleters() - // } + switch cmd.Flag("format").Value.String() { + case "json": + printCompletersJson() + default: + printCompleters() + } }, }