msokolov commented on code in PR #11852: URL: https://github.com/apache/lucene/pull/11852#discussion_r997034628
########## lucene/luke/src/java/org/apache/lucene/luke/app/web/LukeWebMain.java: ########## @@ -17,31 +17,78 @@ package org.apache.lucene.luke.app.web; +import java.net.InetSocketAddress; import java.util.concurrent.CountDownLatch; +import java.util.HashMap; +import java.util.Map; import org.apache.lucene.luke.app.IndexHandler; import org.apache.lucene.luke.util.LoggerFactory; /** Entry class for web Luke */ -public class LukeWebMain { +public final class LukeWebMain { + + private LukeWebMain() { + } static { LoggerFactory.initGuiLogging(); } public static void main(String[] args) throws Exception { - String index = null; - if (args.length == 2 && args[0].equals("--index")) { - index = args[1]; - } else { - System.err.println("usage: LukeWebMain --index <path-to-index>"); - Runtime.getRuntime().exit(1); + Map<String, Object> parsed = null; + try { + parsed = parseArgs(args); + } catch (Exception e) { + usage(e.getMessage()); } - IndexHandler indexHandler = IndexHandler.getInstance(); - indexHandler.open(index, "org.apache.lucene.store.FSDirectory", true, true, false); + indexHandler.open(getIndex(parsed), "org.apache.lucene.store.FSDirectory", true, true, false); CountDownLatch tombstone = new CountDownLatch(1); - HttpService httpService = new HttpService(indexHandler, tombstone); + HttpService httpService = new HttpService(getSockAddr(parsed), indexHandler, tombstone); httpService.start(); tombstone.await(); } + + private static String getIndex(Map<String, Object> args) { + String index = (String) args.get("index"); + if (index == null) { + usage("index arg is required"); + } + return index; + } + + private static InetSocketAddress getSockAddr(Map<String, Object> args) { + String host = (String) args.get("host"); + int port = (Integer) args.getOrDefault("port", 8080); + if (host == null) { + return new InetSocketAddress(port); Review Comment: I think that has already been addressed and we are not talking about the latest version here. (Note the "Outdated" tag on the code snippet above). GitHub UI is a little confusing this way -- I'll add a comment next to the updated version to draw your attention over there -- 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: issues-unsubscr...@lucene.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@lucene.apache.org For additional commands, e-mail: issues-h...@lucene.apache.org