-
Notifications
You must be signed in to change notification settings - Fork 101
/
main.go
87 lines (66 loc) · 1.59 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
package main
import (
"fmt"
"os"
)
const AppVersion = "v14.0.0-pre"
var buildVersion, buildTime string
var versionMessage = fmt.Sprintf(`kt version %s`, AppVersion)
func init() {
if buildVersion == "" && buildTime == "" {
return
}
versionMessage += " ("
if buildVersion != "" {
versionMessage += buildVersion
}
if buildTime != "" {
if buildVersion != "" {
versionMessage += " @ "
}
versionMessage += buildTime
}
versionMessage += ")"
}
var usageMessage = fmt.Sprintf(`kt is a tool for Kafka.
Usage:
kt command [arguments]
The commands are:
consume consume messages.
produce produce messages.
topic topic information.
group consumer group information and modification.
admin basic cluster administration.
Use "kt [command] -help" for more information about the command.
Use "kt -version" for details on what version you are running.
Authentication:
Authentication with Kafka can be configured via a JSON file.
You can set the file name via an "-auth" flag to each command or
set it via the environment variable %s.
You can find more details at https://github.com/fgeller/kt
%s`, ENV_AUTH, versionMessage)
func main() {
if len(os.Args) < 2 {
failf(usageMessage)
}
var cmd command
switch os.Args[1] {
case "consume":
cmd = &consumeCmd{}
case "produce":
cmd = &produceCmd{}
case "topic":
cmd = &topicCmd{}
case "group":
cmd = &groupCmd{}
case "admin":
cmd = &adminCmd{}
case "-h", "-help", "--help":
quitf(usageMessage)
case "-version", "--version":
quitf(versionMessage)
default:
failf(usageMessage)
}
cmd.run(os.Args[2:])
}