diff --git a/commands/admin/topic/topic.go b/commands/admin/topic/topic.go index e2965c4..90bd736 100644 --- a/commands/admin/topic/topic.go +++ b/commands/admin/topic/topic.go @@ -117,13 +117,10 @@ func topicListCommand(cl *client.Client) *cobra.Command { Short: "List all topics", Long: "List all topics (alias for metadata -t)", Run: func(_ *cobra.Command, _ []string) { - args := []string{"-t"} - if detailed { - args = append(args, "-d") - } - cmd := metadata.Command(cl) - cmd.SetArgs(args) - cmd.Execute() + req := kmsg.NewPtrMetadataRequest() + resp, err := req.RequestWith(context.Background(), cl.Client()) + out.MaybeDie(err, "unable to list topics: %v", err) + metadata.PrintTopics(resp.Version, resp.Topics, false, detailed) }, } cmd.Flags().BoolVarP(&detailed, "detailed", "d", false, "include detailed information about all topic partitions") diff --git a/commands/metadata/metadata.go b/commands/metadata/metadata.go index ff02677..e0e5337 100644 --- a/commands/metadata/metadata.go +++ b/commands/metadata/metadata.go @@ -108,7 +108,7 @@ If the brokers section is printed, the controller broker is marked with *. if includeHeader { fmt.Printf("TOPICS\n======\n") } - printTopics(resp.Version, resp.Topics, pinternal, detailed) + PrintTopics(resp.Version, resp.Topics, pinternal, detailed) } }, } @@ -148,7 +148,7 @@ func printBrokers(controllerID int32, brokers []kmsg.MetadataResponseBroker) { } } -func printTopics(version int16, topics []kmsg.MetadataResponseTopic, pinternal, detailed bool) { +func PrintTopics(version int16, topics []kmsg.MetadataResponseTopic, pinternal, detailed bool) { sort.Slice(topics, func(i, j int) bool { l := topics[i].Topic r := topics[j].Topic