GitHub user johnma14 opened a pull request: https://github.com/apache/kafka/pull/3605
KAFKA-2111: Add help arguments and required fields This patch addresses the less invasive standardization of command line arguments as an offshoot of KIP-14. The following changes have been addressed in this patchset: - Used the required() method of JOptSimple to identify required options for commands. Currently, an option is identified as required by mentioning the word REQUIRED in the description of the option. - Used the requiredIf() and requiredUnless() methods to capture option requirements which met the condition - required if/unless some other option is present - Removed calls to CommandLineUtils.checkRequiredArgs(). Since we use JOptSimple's required() function to mark options as required, when we parse the arguments using OptionParser, it automatically checks the required arguments in that call. So there is no need to do this check again externally. - Added a help option to all the commands that were missing it. For some of the commands that had the help option, included the call to forHelp() method to mark the option as a help option. This means that specifying help option on the command line will not cause parsing to fail because of missing required options. - Added try-catch statements to correctly capture OptionException. In the case an OptionException is caught, the command usage information will be printed along with the exception message. The stacktrace for all other exceptions will be printed to System.err. This addresses the issue in KAFKA-4220 - Made some minor changes to the description text and added some more description for some of the options You can merge this pull request into a Git repository by running: $ git pull https://github.com/johnma14/kafka bug/KAFKA-2111 Alternatively you can review and apply these changes as the patch at: https://github.com/apache/kafka/pull/3605.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #3605 ---- commit 97061e37a2f4f4b32fb4353d0e4d8590020225c2 Author: johnma14 <mari...@us.ibm.com> Date: 2017-06-27T23:11:46Z KAFKA-2111: Add help arguments and required fields This patch addresses the less invasive standardization of command line arguments as an offshoot of KIP-14. The following changes have been addressed in this patchset: - Used the required() method of JOptSimple to identify required options for commands. Currently, an option is identified as required by mentioning the word REQUIRED in the description of the option. - Used the requiredIf() and requiredUnless() methods to capture option requirements which met the condition - required if/unless some other option is present - Removed calls to CommandLineUtils.checkRequiredArgs(). Since we use JOptSimple's required() function to mark options as required, when we parse the arguments using OptionParser, it automatically checks the required arguments in that call. So there is no need to do this check again externally. - Added a help option to all the commands that were missing it. For some of the commands that had the help option, included the call to forHelp() method to mark the option as a help option. This means that specifying help option on the command line will not cause parsing to fail because of missing required options. - Added try-catch statements to correctly capture OptionException. In the case an OptionException is caught, the command usage information will be printed along with the exception message. The stacktrace for all other exceptions will be printed to System.err. This addresses the issue in KAFKA-4220 - Made some minor changes to the description text and added some more description for some of the options ---- --- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. ---