Help flag for admin command does not work for subcommands
Opened this issue · 1 comments
Describe the bug
When using the ./accumulo admin
command, help flags -h, --help, -help, -?
will only work at the top level, and will throw an error if set on any subcommand.
./accumulo admin volumes -h
Thread 'admin' died.
com.beust.jcommander.ParameterException: Was passed main parameter '-h' but no main parameter was defined in your arg class
at com.beust.jcommander.JCommander.initMainParameterValue(JCommander.java:961)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:762)
at com.beust.jcommander.JCommander.parse(JCommander.java:363)
at com.beust.jcommander.JCommander.parseValues(JCommander.java:803)
at com.beust.jcommander.JCommander.parse(JCommander.java:363)
at com.beust.jcommander.JCommander.parse(JCommander.java:342)
at org.apache.accumulo.server.util.Admin.execute(Admin.java:342)
at org.apache.accumulo.start.Main.lambda$execKeyword$0(Main.java:81)
at java.base/java.lang.Thread.run(Thread.java:842)
Due to the amount of subcommands, the top-level usage statement is large and typically scrolls off a terminal window.
Versions (OS, Maven, Java, and others, as appropriate):
- Affected version(s) of this project: [e.g. 1.10.0] 2.1.x
To Reproduce
Steps to reproduce the behavior (or a link to an example repository that reproduces the problem):
- Run the accumulo admin command with any subcommand and add any of the help flags
./accumulo admin dumpConfig --help
- See a Parameter Exception stack trace
Expected behavior
The help flag should work with any subcommand used in the admin command
@ddanielr looking at the accumulo admin command usage states:
Usage: accumulo admin [options] [command] [command options]
Options:
-auths, --auths
the authorizations to use when reading or writing
Default: <empty string>
-c, --config-file
Read the given client config file. If omitted, the classpath will be
searched for file named accumulo-client.properties
-f, --force
force the given server to stop by removing its lock
Default: false
-h, -?, --help, -help
......
The usage indicates that the help flags should appear between the admin
and command
values. None of the sub- commands themselves have any help flags listed. It appears the initial code only provided a help command for the overall admin command.
I went through each sub-command and If you execute each sub-command using that format no errors are thrown, but rather the entire accumulo admin
help message is displayed.
The one exception is the randomizeVolumes
command. This command will throw an exception if the -t <table>
info is not provided.
I agree that it would nice if help info would be provided if a help flag was used anywhere on the command line, but I'm not sure if this is a bug or just a design choice that was made. I'm not sure how to best let the user know that the help flags should be earlier on the command line. Perhaps it should be considered an enhancement/improvement issue instead. What are your thoughts?