-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_topic.go
42 lines (35 loc) · 1.04 KB
/
get_topic.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/*
Copyright © 2023 NAME HERE <EMAIL ADDRESS>
*/
package cmd
import (
"fmt"
"strings"
"github.com/spf13/cobra"
)
// topicCmd represents the topic command
var getTopicCmd = &cobra.Command{
Use: "topic",
Aliases: []string{"to", "topics"},
Short: "List kafka topics produced by the fink-broker",
Run: func(cmd *cobra.Command, args []string) {
logger.Info("List kafka topics produced by the fink-broker")
topics, err := getFinkTopics()
cobra.CheckErr(err)
if len(topics) == 0 {
fmt.Println("No fink topics found")
} else {
fmt.Println(strings.Join(topics, "\n"))
}
},
}
func init() {
getCmd.AddCommand(getTopicCmd)
// Here you will define your flags and configuration settings.
// Cobra supports Persistent Flags which will work for this command
// and all subcommands, e.g.:
// topicCmd.PersistentFlags().String("foo", "", "A help for foo")
// Cobra supports local flags which will only run when this command
// is called directly, e.g.:
// topicCmd.Flags().BoolP("toggle", "t", false, "Help message for toggle")
}