Fix bookie shell help command exception
authorHang Chen <chenhang@apache.org>
Mon, 25 Apr 2022 22:35:16 +0000 (06:35 +0800)
committerGitHub <noreply@github.com>
Mon, 25 Apr 2022 22:35:16 +0000 (15:35 -0700)
commitb7128977d466c6e113b1d576b88d9f1e70689ad7
treefe5ee39bc66eec2320a0c5b3f595a6cc5e2a5ccf
parentb17969e07fbb3a0ca5ec3c374a4fab27e87add17
Fix bookie shell help command exception

### Motivation
When run `bin/bookkeeper shell ledgermetadata -h` command, it throw the following exception.
```
23:02:41,236 ERROR Error parsing command line arguments :
org.apache.commons.cli.UnrecognizedOptionException: Unrecognized option: -h
at org.apache.commons.cli.Parser.processOption(Parser.java:363) ~[commons-cli-commons-cli-1.2.jar:1.2]
at org.apache.commons.cli.Parser.parse(Parser.java:199) ~[commons-cli-commons-cli-1.2.jar:1.2]
at org.apache.commons.cli.Parser.parse(Parser.java:85) ~[commons-cli-commons-cli-1.2.jar:1.2]
at org.apache.bookkeeper.bookie.BookieShell$MyCommand.runCmd(BookieShell.java:240) ~[org.apache.bookkeeper-bookkeeper-server-4.16.0-SNAPSHOT.jar:4.16.0-SNAPSHOT]
at org.apache.bookkeeper.bookie.BookieShell.run(BookieShell.java:2372) ~[org.apache.bookkeeper-bookkeeper-server-4.16.0-SNAPSHOT.jar:4.16.0-SNAPSHOT]
at org.apache.bookkeeper.bookie.BookieShell.main(BookieShell.java:2463) ~[org.apache.bookkeeper-bookkeeper-server-4.16.0-SNAPSHOT.jar:4.16.0-SNAPSHOT]
ledgermetadata: Print the metadata for a ledger, or optionally dump to a file.
usage: ledgermetadata -ledgerid <ledgerid> [--dump-to-file
                      FILENAME|--restore-from-file FILENAME]
 -dumptofile <arg>        Dump metadata for ledger, to a file
 -l,--ledgerid <arg>      Ledger ID
 -restorefromfile <arg>   Restore metadata for ledger, from a file
```

### Changes
Add `-h` and `--help` support.

Reviewers: Enrico Olivelli <eolivelli@gmail.com>, ZhangJian He <shoothzj@gmail.com>, Andrey Yegorov <None>

This closes #3227 from hangc0276/chenhang/fix_bookieshell_help_exception
bookkeeper-server/src/main/java/org/apache/bookkeeper/bookie/BookieShell.java