apache / apache/bookkeeper

Expect to display help information when using shell command with no args

Open
#2,148 0 comments 0 reactions 0 assignees View on GitHub
triage/week-15 type/bug
Dominant language
Java
Stars
2k
Forks
976
Avg merge
6d 15h
Merged PRs (30d)
7

Description

***Describe the bug***

When using the subcommands of `bookkeeper shell` with no args, it throws excepiton, such as below:
```
$ bin/bookkeeper shell cookie_generate
... ...
16:03:25.824 [main-EventThread] INFO org.apache.bookkeeper.zookeeper.ZooKeeperWatcherBase - ZooKeeper client is connected now.
16:03:25.856 [main] INFO org.apache.zookeeper.ZooKeeper - Session: 0x300001319580058 closed
16:03:25.856 [main-EventThread] INFO org.apache.zookeeper.ClientCnxn - EventThread shut down for session: 0x300001319580058
Failed to process cookie command 'generate'
java.lang.IllegalArgumentException: No bookie id or more bookie ids is specified
at com.google.common.base.Preconditions.checkArgument(Preconditions.java:122)
at org.apache.bookkeeper.tools.cli.commands.cookie.CookieCommand.getBookieId(CookieCommand.java:89)
at org.apache.bookkeeper.tools.cli.commands.cookie.GenerateCookieCommand.apply(GenerateCookieCommand.java:102)
at org.apache.bookkeeper.tools.cli.commands.cookie.GenerateCookieCommand.apply(GenerateCookieCommand.java:39)
at org.apache.bookkeeper.tools.cli.commands.cookie.CookieCommand.lambda$apply$0(CookieCommand.java:71)
at org.apache.bookkeeper.meta.MetadataDrivers.lambda$runFunctionWithRegistrationManager$1(MetadataDrivers.java:398)
at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithMetadataBookieDriver(MetadataDrivers.java:373)
at org.apache.bookkeeper.meta.MetadataDrivers.runFunctionWithRegistrationManager(MetadataDrivers.java:398)
at org.apache.bookkeeper.tools.cli.commands.cookie.CookieCommand.apply(CookieCommand.java:69)
at org.apache.bookkeeper.tools.common.BKCommand.lambda$apply$1(BKCommand.java:62)
at org.apache.bookkeeper.tools.framework.Cli.run(Cli.java:224)
at org.apache.bookkeeper.tools.framework.Cli.runCli(Cli.java:244)
at org.apache.bookkeeper.tools.common.BKCommand.apply(BKCommand.java:64)
at org.apache.bookkeeper.tools.cli.helpers.BookieShellCommand.runCmd(BookieShellCommand.java:46)
at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:3081)
at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:3172)
```
It will be better to print the usage of the subcommand for the beginners.
```
[root@kube2 bookkeeper-server-4.10.0-SNAPSHOT]# bin/bookkeeper shell cookie_generate
Generate a cookie for a given bookie

Usage: generate [flags]

Flags:

-i, --instance-id
The instance id of the cluster that this bookie belongs to. If omitted,
it will used the instance id of the cluster that this cli connects to.

-j, --journal-dirs (*)
The journal directories used by this bookie

-l, --ledger-dirs (*)
The ledger directories used by this bookie

-o, --output-file (*)
The output file to save the generated cookie.

-h, --help
Display help information
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.