Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@

import org.apache.commons.cli.CommandLine;
import org.apache.commons.cli.DefaultParser;
import org.apache.commons.cli.HelpFormatter;
import org.apache.commons.cli.Option;
import org.apache.commons.cli.Options;
import org.apache.commons.cli.ParseException;
import org.apache.commons.cli.help.HelpFormatter;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.core.storage.json.internal.JsonStorage;
Expand Down Expand Up @@ -69,15 +69,15 @@ private static Options getOptions() {

options.addOption(Option.builder().longOpt(OPT_USERDATA_DIR).desc(
"USERDATA directory to process. Enclose it in double quotes to ensure that any backslashes are not ignored by your command shell.")
.numberOfArgs(1).build());
.numberOfArgs(1).get());
options.addOption(Option.builder().longOpt(OPT_CONF_DIR).desc(
"CONF directory to process. Enclose it in double quotes to ensure that any backslashes are not ignored by your command shell.")
.numberOfArgs(1).build());
.numberOfArgs(1).get());
options.addOption(Option.builder().longOpt(OPT_COMMAND).numberOfArgs(1)
.desc("command to execute (executes all if omitted)").build());
options.addOption(Option.builder().longOpt(OPT_LIST_COMMANDS).desc("list available commands").build());
options.addOption(Option.builder().longOpt(OPT_LOG).numberOfArgs(1).desc("log verbosity").build());
options.addOption(Option.builder().longOpt(OPT_FORCE).desc("force execution (even if already done)").build());
.desc("command to execute (executes all if omitted)").get());
options.addOption(Option.builder().longOpt(OPT_LIST_COMMANDS).desc("list available commands").get());
options.addOption(Option.builder().longOpt(OPT_LOG).numberOfArgs(1).desc("log verbosity").get());
options.addOption(Option.builder().longOpt(OPT_FORCE).desc("force execution (even if already done)").get());

return options;
}
Expand Down Expand Up @@ -143,8 +143,13 @@ public static void main(String[] args) {
}
});
} catch (ParseException e) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("upgradetool", "", options, "", true);
HelpFormatter formatter = HelpFormatter.builder().get();
try {
formatter.printHelp("upgradetool", "", options, "", true);
} catch (Exception ex) {
// In case of an error while printing help, print the error and exit
LOGGER.error("Error printing help: {}", ex.getMessage());
}
}

System.exit(0);
Expand Down