Skip to content
This repository has been archived by the owner on Apr 15, 2024. It is now read-only.

ISSUE-2148: Expect to display help information when using shell command with no args #173

Open
sijie opened this issue Jan 15, 2020 · 0 comments

Comments

@sijie
Copy link
Member

sijie commented Jan 15, 2020

Original Issue: apache#2148


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] <bookie-id>

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
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant