Skip to content

Commit

Permalink
#1 Fix panic error thrown on help command
Browse files Browse the repository at this point in the history
  • Loading branch information
fhussonnois committed Apr 24, 2017
1 parent c24d460 commit 6cbaa05
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
10 changes: 7 additions & 3 deletions cmd/kafkaconnectcli/kafkaconnectcli.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,12 @@ func main() {
case "scale":
commandArgParser = ScaleArgParser
case "help":
fmt.Printf("Usage of %s: %s\nThe arguments are :\n", os.Args[2], Commands[os.Args[2]])
switch os.Args[2] {
if len(os.Args) < 3 {
usage()
}
subCommand := os.Args[2]
fmt.Printf("Usage of %s: %s\nThe arguments are :\n", subCommand, Commands[subCommand])
switch subCommand {
case "config", "status", "delete", "resume", "pause", "tasks", "restart-failed":
ConnectorArgParser.Flag.PrintDefaults()
case "create":
Expand All @@ -208,7 +212,7 @@ func main() {
case "delete-all", "plugins", "version":
CommonArgParser.Flag.PrintDefaults()
default:
fmt.Fprint(os.Stderr, "Unknown help command `"+os.Args[2]+"`. Run '"+os.Args[0]+" help'.\n")
fmt.Fprint(os.Stderr, "Unknown help command `"+subCommand+"`. Run '"+os.Args[0]+" help'.\n")
}
os.Exit(1)
default:
Expand Down
9 changes: 7 additions & 2 deletions cmd/schemaregistrycli/registrycli.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,12 @@ func main() {
case "test":
commandArgParser = TestCompatibilityArgParser
case "help":
switch os.Args[2] {
if len(os.Args) < 3 {
usage()
}
subCommand := os.Args[2]
fmt.Printf("Usage of %s: %s\nThe arguments are :\n", subCommand, Commands[subCommand])
switch subCommand {
case "subjects", "global-compatibility":
CommonArgParser.Flag.PrintDefaults()
case "versions", "compatibility":
Expand All @@ -254,7 +259,7 @@ func main() {
case "test":
TestCompatibilityArgParser.Flag.PrintDefaults()
default:
fmt.Fprint(os.Stderr, "Unknown help command `"+os.Args[2]+"`. Run '"+os.Args[0]+" help'.\n")
fmt.Fprint(os.Stderr, "Unknown help command `"+subCommand+"`. Run '"+os.Args[0]+" help'.\n")
}
os.Exit(1)
default:
Expand Down

0 comments on commit 6cbaa05

Please sign in to comment.