This repository has been archived by the owner on May 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Mick Staugaard
committed
Jun 11, 2020
1 parent
e2b2208
commit dd26cb7
Showing
3 changed files
with
186 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package cmd | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/spf13/cobra" | ||
) | ||
|
||
// listTopicsCmd represents the listTopics command | ||
var listTopicsCmd = &cobra.Command{ | ||
Use: "listTopics", | ||
Short: "List all the topics", | ||
Long: `listTopics all the topics. Example: | ||
kafkaCLI listTopics --bootstrap-server kafka:9092 | ||
`, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
admin := kafkaAdmin() | ||
topics, err := admin.ListTopics() | ||
if err != nil { | ||
panic(err) | ||
} | ||
|
||
for name, _ := range topics { | ||
fmt.Println(name) | ||
} | ||
|
||
_ = admin.Close() | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(listTopicsCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.