-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
46 lines (39 loc) · 1.28 KB
/
main.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
43
44
45
46
package main
import (
"os"
"fmt"
"github.com/spf13/cobra"
)
func getenv(key string, defaultVal string) string {
if value, ok := os.LookupEnv(key); ok {
return value
}
return defaultVal
}
const version = "0.1.0"
var cmdVersion = &cobra.Command{
Use: "version",
Short: "Version",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println(version, "https://github.com/lala7573/kafka-connect-cli")
},
}
func main() {
cmdRoot := &cobra.Command{Use: os.Args[0]}
cmdRoot.PersistentFlags().StringVarP(&config.KAFKA_CONNECT_REST, "endpoint", "e", getenv("KAFKA_CONNECT_REST", "http://localhost:8083/"), "kafka connect rest")
cmdRoot.PersistentFlags().StringVarP(&config.FORMAT, "format", "f", "properties", "format: properties | json")
cmdRoot.AddCommand(cmdPlugins)
cmdRoot.AddCommand(cmdConnectorList)
cmdRoot.AddCommand(cmdConnectorGet)
cmdRoot.AddCommand(cmdConnectorStatus)
cmdRoot.AddCommand(cmdConnectorCreate)
cmdRoot.AddCommand(cmdConnectorUpdate)
cmdRoot.AddCommand(cmdConnectorDelete)
cmdRoot.AddCommand(cmdConnectorPause)
cmdRoot.AddCommand(cmdConnectorResume)
cmdRoot.AddCommand(cmdConnectorRestart)
cmdRoot.AddCommand(cmdConnectorValidate)
cmdRoot.AddCommand(cmdVersion)
cmdRoot.AddCommand(cmdCompletion)
cmdRoot.Execute()
}