Skip to content

Commit 9f202b0

Browse files
authored
Optimize bookie usage information while using command line option --help (#4241)
1 parent 55ffbd7 commit 9f202b0

File tree

1 file changed

+14
-3
lines changed
  • bookkeeper-server/src/main/java/org/apache/bookkeeper/server

1 file changed

+14
-3
lines changed

bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java

+14-3
Original file line numberDiff line numberDiff line change
@@ -109,12 +109,13 @@ private static ServerConfiguration parseArgs(String[] args)
109109
BasicParser parser = new BasicParser();
110110
CommandLine cmdLine = parser.parse(BK_OPTS, args);
111111

112+
ServerConfiguration conf = new ServerConfiguration();
113+
112114
if (cmdLine.hasOption('h')) {
113-
throw new IllegalArgumentException();
115+
conf.setProperty("help", true);
116+
return conf;
114117
}
115118

116-
ServerConfiguration conf = new ServerConfiguration();
117-
118119
if (cmdLine.hasOption('c')) {
119120
String confFile = cmdLine.getOptionValue("c");
120121
loadConfFile(conf, confFile);
@@ -210,6 +211,11 @@ static int doMain(String[] args) {
210211
return ExitCode.INVALID_CONF;
211212
}
212213

214+
if (conf.getBoolean("help", false)) {
215+
printUsage();
216+
return ExitCode.OK;
217+
}
218+
213219
// 1. building the component stack:
214220
LifecycleComponent server;
215221
try {
@@ -244,6 +250,11 @@ private static ServerConfiguration parseCommandLine(String[] args)
244250
printUsage();
245251
throw iae;
246252
}
253+
254+
if (conf.getBoolean("help", false)) {
255+
return conf;
256+
}
257+
247258
String hello = String.format(
248259
"Hello, I'm your bookie, bookieId is %1$s, listening on port %2$s. Metadata service uri is %3$s."
249260
+ " Journals are in %4$s. Ledgers are stored in %5$s. Indexes are stored in %6$s.",

0 commit comments

Comments
 (0)