Skip to content

Commit

Permalink
config: add add-cluster command
Browse files Browse the repository at this point in the history
  • Loading branch information
birdayz committed Oct 5, 2018
1 parent 219495e commit c2371d2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions cmd/kaf/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ func init() {
configCmd.AddCommand(configImportCmd)
configCmd.AddCommand(configUseCmd)
configCmd.AddCommand(configLsCmd)
configCmd.AddCommand(configAddClusterCmd)
rootCmd.AddCommand(configCmd)
}

Expand Down Expand Up @@ -48,6 +49,23 @@ var configLsCmd = &cobra.Command{
},
}

var configAddClusterCmd = &cobra.Command{
Use: "add-cluster [NAME]",
Short: "add cluster",
Args: cobra.ExactArgs(1),
Run: func(cmd *cobra.Command, args []string) {
config.Clusters = append(config.Clusters, &kaf.Cluster{
Name: args[0],
Brokers: brokersFlag,
})
err := config.Write()
if err != nil {
panic(err)
}
fmt.Println("Added cluster.")
},
}

var configImportCmd = &cobra.Command{
Use: "import [ccloud]",
Short: "Import configurations into the $HOME/.kaf/config file",
Expand Down

0 comments on commit c2371d2

Please sign in to comment.