ksravista commented on code in PR #143:
URL:
https://github.com/apache/hbase-operator-tools/pull/143#discussion_r1626418411
##########
hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java:
##########
@@ -1507,22 +1577,39 @@ private Pair<CommandLine, List<String>>
parseCommandWithFixAndInputOptions(Strin
return Pair.newPair(commandLine, params);
}
+ private boolean commandHasHelpOption(String[] args) {
+ args = purgeFirst(args);
+ Options options = new Options();
+ Option helpOption =
+ Option.builder("h").longOpt("help").desc("help message for a
command").build();
+
+ options.addOption(helpOption);
+ CommandLine test = getCommandLine(args, options, false);
+ return test != null && test.hasOption(helpOption.getOpt());
+ }
+
/**
* Get a commandLine object with options and a arg list
*/
- private CommandLine getCommandLine(String[] args, Options options) {
+ private CommandLine getCommandLine(String[] args, Options options, boolean
showException) {
// Parse command-line.
CommandLineParser parser = new DefaultParser();
CommandLine commandLine;
try {
commandLine = parser.parse(options, args, false);
} catch (ParseException e) {
- showErrorMessage(e.getMessage());
+ if (showException) {
+ showErrorMessage(e.getMessage());
+ }
return null;
}
return commandLine;
}
+ private CommandLine getCommandLine(String[] args, Options options) {
+ return getCommandLine(args, options, true);
+ }
Review Comment:
Yes, this is used in various places. I just refactored the default to print
the error statement, but for the check for `-h` option, we do not need log
statement printed.
eg.
https://github.com/apache/hbase-operator-tools/blob/master/hbase-hbck2/src/main/java/org/apache/hbase/HBCK2.java#L206
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]