Fix panic when no args supplied to cli-doc (#1048)

Fixes: #1047
This commit is contained in:
Georgios Andrianakis
2018-11-27 11:53:56 +02:00
committed by Suraj Narwade
parent 79925b6389
commit 2d9ab2825a

View File

@@ -143,13 +143,17 @@ func main() {
ValidArgs: []string{"help", "reference", "structure"},
Run: func(command *cobra.Command, args []string) {
switch args[0] {
case "reference":
fmt.Print(referencePrinter(cli.RootCmd(), 0))
case "structure":
fmt.Print(commandPrinter(cli.RootCmd(), 0))
default:
if len(args) == 0 {
fmt.Print(command.Usage())
} else {
switch args[0] {
case "reference":
fmt.Print(referencePrinter(cli.RootCmd(), 0))
case "structure":
fmt.Print(commandPrinter(cli.RootCmd(), 0))
default:
fmt.Print(command.Usage())
}
}
},
}