From 92fe4f99d78a2fe468969ab8f1ee724a6f19643d Mon Sep 17 00:00:00 2001 From: Kang Zou Date: Fri, 22 Mar 2024 10:49:41 +0800 Subject: [PATCH] Optimize bookie usage information while using command line option --help --- .../java/org/apache/bookkeeper/server/Main.java | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java index decc32c24a0..3eff455a840 100644 --- a/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java +++ b/bookkeeper-server/src/main/java/org/apache/bookkeeper/server/Main.java @@ -109,12 +109,13 @@ private static ServerConfiguration parseArgs(String[] args) BasicParser parser = new BasicParser(); CommandLine cmdLine = parser.parse(BK_OPTS, args); + ServerConfiguration conf = new ServerConfiguration(); + if (cmdLine.hasOption('h')) { - throw new IllegalArgumentException(); + conf.setProperty("help", true); + return conf; } - ServerConfiguration conf = new ServerConfiguration(); - if (cmdLine.hasOption('c')) { String confFile = cmdLine.getOptionValue("c"); loadConfFile(conf, confFile); @@ -210,6 +211,11 @@ static int doMain(String[] args) { return ExitCode.INVALID_CONF; } + if (conf.getBoolean("help", false)) { + printUsage(); + return ExitCode.OK; + } + // 1. building the component stack: LifecycleComponent server; try { @@ -244,6 +250,11 @@ private static ServerConfiguration parseCommandLine(String[] args) printUsage(); throw iae; } + + if (conf.getBoolean("help", false)) { + return conf; + } + String hello = String.format( "Hello, I'm your bookie, bookieId is %1$s, listening on port %2$s. Metadata service uri is %3$s." + " Journals are in %4$s. Ledgers are stored in %5$s. Indexes are stored in %6$s.",