List of usage examples for org.apache.commons.cli CommandLine hasOption
public boolean hasOption(char opt)
From source file:com.ricston.akka.matrix.Main.java
public static void main(String[] args) throws InterruptedException, NumberFormatException, IOException { CommandLineParser parser = new GnuParser(); int numberOfActors = -1; Options options = new Options(); // Set the command line options recognized by this program. setUpCLOptions(options);/*from w ww .j av a 2 s . com*/ // Parse the command line arguments. CommandLine cmd = null; try { cmd = parser.parse(options, args); } catch (ParseException e) { quitApp(options); } if (cmd.hasOption(ACTORS)) { // Set the number of actors to create if the user supplied this argument. numberOfActors = Integer.parseInt(cmd.getOptionValue(ACTORS)); } if (cmd.hasOption(GENERATE)) { // Generate a file containing two randomly generated matrices. String[] genArgs = cmd.getOptionValues(GENERATE); if (genArgs.length != 5) { quitApp(options); } MatrixFile.writeMatrixFile(genArgs[0], generateMatrix(Integer.parseInt(genArgs[1]), Integer.parseInt(genArgs[2])), generateMatrix(Integer.parseInt(genArgs[3]), Integer.parseInt(genArgs[4])), new ArrayList<List<Double>>()); } if (cmd.hasOption(COMPUTE)) { // Compute the matrix multiplication of the matrices in the files // given as argument. String[] compArgs = cmd.getOptionValues(COMPUTE); ActorRef managerRef = null; if (numberOfActors > 0) { final int actors = numberOfActors; managerRef = actorOf(new UntypedActorFactory() { public UntypedActor create() { return new ManagerActor(actors); } }); } else { managerRef = actorOf(ManagerActor.class); } // Start the manager actor. managerRef.start(); // Create and send an AllJobsMsg. managerRef.tell(new AllJobsMsg(compArgs)); } if (cmd.getArgs().length > 0 || args.length == 0) { // Handle unrecognized arguments. quitApp(options); } }
From source file:com.ibm.soatf.SOATestingFramework.java
/** * SOA Testing Framework main static method. * * @param args Main input parameters./*ww w . j a v a2 s.c om*/ */ public static void main(String[] args) { Options options = new Options(); options.addOption(new Option("gui", "Display a GUI")); options.addOption(OptionBuilder.withArgName("environment").hasArg() .withDescription("Environment to run the tests on").create("env")); // has a value options.addOption(OptionBuilder.withArgName("project").hasArg() .withDescription("Project to run the tests on").create("p")); // has a value options.addOption(OptionBuilder.withArgName("interface").hasArg() .withDescription("Interface to run the tests on").create("i")); // has a value CommandLineParser parser = new BasicParser(); try { CommandLine cmd = parser.parse(options, args); validate(cmd); if (cmd.hasOption("gui")) { /* Set the Nimbus look and feel */ //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ try { if (false) { //disabled the OS Look'n'Feel UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } else { for (UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } UIManager.getLookAndFeelDefaults().put("nimbusOrange", (new Color(0, 128, 255))); } } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) { logger.error("Cannot set look and feel", ex); } //</editor-fold> final SOATestingFrameworkGUI soatfgui = new SOATestingFrameworkGUI(); java.awt.EventQueue.invokeLater(new Runnable() { @Override public void run() { soatfgui.setVisible(true); } }); } else { //<editor-fold defaultstate="collapsed" desc="Command line mode"> try { // Initialization of configuration manager. ConfigurationManager.getInstance().init(); String env = cmd.getOptionValue("env", null); String ifaceName; boolean inboundOnly = false; if (cmd.hasOption("p")) { String projectName = cmd.getOptionValue("p"); MasterConfiguration masterConfig = ConfigurationManager.getInstance().getMasterConfig(); List<SOATestingFrameworkMasterConfiguration.Interfaces.Interface> interfaces = masterConfig .getInterfaces(); all: for (Interface iface : interfaces) { List<Project> projects = iface.getProjects().getProject(); for (Project project : projects) { if (project.getName().equals(projectName)) { inboundOnly = "INBOUND".equalsIgnoreCase(project.getDirection()); ifaceName = iface.getName(); break all; } } } throw new FrameworkExecutionException( "No such project found in master configuration: " + projectName); } else { ifaceName = cmd.getOptionValue("i"); inboundOnly = false; } DirectoryStructureManager.checkFrameworkDirectoryStructure(ifaceName); FlowExecutor flowExecutor = new FlowExecutor(inboundOnly, env, ifaceName); flowExecutor.execute(); } catch (FrameworkConfigurationException ex) { logger.fatal("Configuration corrupted. See the exception stack trace for details.", ex); } catch (FrameworkException ex) { logger.fatal(ex); } //</editor-fold> } } catch (ParseException ex) { logger.fatal("Could not parse the command line arguments. Reason: " + ex); printUsage(); } catch (Throwable ex) { logger.fatal("Unexpected error occured: ", ex); printUsage(); System.exit(-1); } }
From source file:com.jgaap.backend.CLI.java
/** * Parses the arguments passed to jgaap from the command line. Will either * display the help or run jgaap on an experiment. * /* w w w . ja va2 s. c om*/ * @param args * command line arguments * @throws Exception */ public static void main(String[] args) throws Exception { CommandLineParser parser = new GnuParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption('h')) { String command = cmd.getOptionValue('h'); if (command == null) { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.setLeftPadding(5); helpFormatter.setWidth(100); helpFormatter.printHelp( "jgaap -c [canon canon ...] -es [event] -ec [culler culler ...] -a [analysis] <-d [distance]> -l [file] <-s [file]>", "Welcome to JGAAP the Java Graphical Authorship Attribution Program.\nMore information can be found at http://jgaap.com", options, "Copyright 2013 Evaluating Variation in Language Lab, Duquesne University"); } else { List<Displayable> list = new ArrayList<Displayable>(); if (command.equalsIgnoreCase("c")) { list.addAll(Canonicizers.getCanonicizers()); } else if (command.equalsIgnoreCase("es")) { list.addAll(EventDrivers.getEventDrivers()); } else if (command.equalsIgnoreCase("ec")) { list.addAll(EventCullers.getEventCullers()); } else if (command.equalsIgnoreCase("a")) { list.addAll(AnalysisDrivers.getAnalysisDrivers()); } else if (command.equalsIgnoreCase("d")) { list.addAll(DistanceFunctions.getDistanceFunctions()); } else if (command.equalsIgnoreCase("lang")) { list.addAll(Languages.getLanguages()); } for (Displayable display : list) { if (display.showInGUI()) System.out.println(display.displayName() + " - " + display.tooltipText()); } if (list.isEmpty()) { System.out.println("Option " + command + " was not found."); System.out.println("Please use c, es, d, a, or lang"); } } } else if (cmd.hasOption('v')) { System.out.println("Java Graphical Authorship Attribution Program version 5.2.0"); } else if (cmd.hasOption("ee")) { String eeFile = cmd.getOptionValue("ee"); String lang = cmd.getOptionValue("lang"); ExperimentEngine.runExperiment(eeFile, lang); System.exit(0); } else { JGAAP.commandline = true; API api = API.getPrivateInstance(); String documentsFilePath = cmd.getOptionValue('l'); if (documentsFilePath == null) { throw new Exception("No Documents CSV specified"); } List<Document> documents; if (documentsFilePath.startsWith(JGAAPConstants.JGAAP_RESOURCE_PACKAGE)) { documents = Utils.getDocumentsFromCSV( CSVIO.readCSV(com.jgaap.JGAAP.class.getResourceAsStream(documentsFilePath))); } else { documents = Utils.getDocumentsFromCSV(CSVIO.readCSV(documentsFilePath)); } for (Document document : documents) { api.addDocument(document); } String language = cmd.getOptionValue("lang", "english"); api.setLanguage(language); String[] canonicizers = cmd.getOptionValues('c'); if (canonicizers != null) { for (String canonicizer : canonicizers) { api.addCanonicizer(canonicizer); } } String[] events = cmd.getOptionValues("es"); if (events == null) { throw new Exception("No EventDriver specified"); } for (String event : events) { api.addEventDriver(event); } String[] eventCullers = cmd.getOptionValues("ec"); if (eventCullers != null) { for (String eventCuller : eventCullers) { api.addEventCuller(eventCuller); } } String analysis = cmd.getOptionValue('a'); if (analysis == null) { throw new Exception("No AnalysisDriver specified"); } AnalysisDriver analysisDriver = api.addAnalysisDriver(analysis); String distanceFunction = cmd.getOptionValue('d'); if (distanceFunction != null) { api.addDistanceFunction(distanceFunction, analysisDriver); } api.execute(); List<Document> unknowns = api.getUnknownDocuments(); OutputStreamWriter outputStreamWriter; String saveFile = cmd.getOptionValue('s'); if (saveFile == null) { outputStreamWriter = new OutputStreamWriter(System.out); } else { outputStreamWriter = new OutputStreamWriter(new FileOutputStream(saveFile)); } Writer writer = new BufferedWriter(outputStreamWriter); for (Document unknown : unknowns) { writer.append(unknown.getFormattedResult(analysisDriver)); } writer.append('\n'); } }
From source file:com.yahoo.pasc.paxos.server.PaxosServer.java
/** * @param args// w w w . java2s .c o m * @throws NoSuchFieldException * @throws SecurityException * @throws IOException * @throws MalformedURLException */ public static void main(String[] args) throws SecurityException, NoSuchFieldException, IOException { CommandLineParser parser = new PosixParser(); Options options; { Option id = new Option("i", true, "client id"); Option port = new Option("p", true, "port used by server"); Option buffer = new Option("b", true, "number of batched messages"); // Option clients = new Option("c", true, "clients (hostname:port,...)"); Option servers = new Option("s", true, "servers (hostname:port,...)"); Option maxInstances = new Option("m", true, "max number of instances"); Option anm = new Option("a", false, "protection against ANM faults"); Option udp = new Option("u", false, "use UDP"); Option cWindow = new Option("w", true, "congestion window"); Option threads = new Option("t", true, "number of threads"); Option digests = new Option("d", true, "max digests"); Option ckPeriod = new Option("k", true, "checkpointing period"); Option inlineThresh = new Option("n", true, "threshold for sending requests iNline with accepts "); Option twoStages = new Option("2", false, "2 stages"); Option digestQuorum = new Option("q", true, "digest quorum"); Option leaderReplies = new Option("r", false, "leader replies"); Option zookeeper = new Option("z", true, "zookeeper connection string"); options = new Options(); options.addOption(id).addOption(port).addOption(buffer).addOption(servers).addOption(threads) .addOption(anm).addOption(udp).addOption(maxInstances) //.addOption(leader) .addOption(cWindow).addOption(digests).addOption(ckPeriod).addOption(inlineThresh) .addOption(twoStages).addOption(digestQuorum).addOption(leaderReplies).addOption(zookeeper); } CommandLine line = null; try { line = parser.parse(options, args); String serverAddresses[] = line.hasOption('s') ? line.getOptionValue('s').split(",") : new String[] { "10.78.36.104:20548", "10.78.36.104:20748" }; // String clientAddresses[] = line.hasOption('c') ? line.getOptionValue('c').split(",") : new String[] { "localhost:9000" }; String zookeeper = line.hasOption('z') ? line.getOptionValue('z') : "localhost:2181"; int serverId = line.hasOption('i') ? Integer.parseInt(line.getOptionValue('i')) : 0; int batchSize = line.hasOption('b') ? Integer.parseInt(line.getOptionValue('b')) : 1; int port = line.hasOption('p') ? Integer.parseInt(line.getOptionValue('p')) : 20548; int maxInstances = line.hasOption('m') ? Integer.parseInt(line.getOptionValue('m')) : 16 * 1024; int congestionWindow = line.hasOption('w') ? Integer.parseInt(line.getOptionValue('w')) : 1; int digests = line.hasOption('d') ? Integer.parseInt(line.getOptionValue('d')) : 16; int inlineThreshold = line.hasOption('n') ? Integer.parseInt(line.getOptionValue('n')) : 1000; boolean protection = line.hasOption('a'); boolean udp = line.hasOption('u'); boolean twoStages = line.hasOption('2'); int quorum = serverAddresses.length / 2 + 1; int digestQuorum = line.hasOption('q') ? Integer.parseInt(line.getOptionValue('q')) : quorum; int threads = line.hasOption('t') ? Integer.parseInt(line.getOptionValue('t')) : Runtime.getRuntime().availableProcessors() * 2 + 1; if (batchSize <= 0) { throw new RuntimeException("BatchSize must be greater than 0"); } PaxosState state = new PaxosState(maxInstances, batchSize, serverId, quorum, digestQuorum, serverAddresses.length, congestionWindow, digests); if (line.hasOption('k')) state.setCheckpointPeriod(Integer.parseInt(line.getOptionValue('k'))); if (line.hasOption('r')) state.setLeaderReplies(true); state.setRequestThreshold(inlineThreshold); if (!protection) { System.out.println("PANM disabled!"); } final PascRuntime<PaxosState> runtime = new PascRuntime<PaxosState>(protection); runtime.setState(state); runtime.addHandler(Accept.class, new AcceptorAccept()); runtime.addHandler(Prepare.class, new AcceptorPrepare()); runtime.addHandler(Accepted.class, new Learner()); runtime.addHandler(Prepared.class, new ProposerPrepared()); runtime.addHandler(Request.class, new ProposerRequest()); runtime.addHandler(InlineRequest.class, new ProposerRequest()); runtime.addHandler(Digest.class, new DigestHandler()); runtime.addHandler(PreReply.class, new LearnerPreReply()); runtime.addHandler(Leader.class, new LeadershipHandler()); if (udp) { new UdpServer(runtime, serverAddresses, null, port, threads, serverId).run(); } else { new TcpServer(runtime, new EmptyStateMachine(), null, zookeeper, serverAddresses, port, threads, serverId, twoStages).run(); } } catch (Exception e) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("Paxos", options); System.err.println("Unexpected exception: " + e); e.printStackTrace(); System.exit(-1); } }
From source file:de.peran.DependencyReadingStarter.java
public static void main(final String[] args) throws ParseException, FileNotFoundException { final Options options = OptionConstants.createOptions(OptionConstants.FOLDER, OptionConstants.STARTVERSION, OptionConstants.ENDVERSION, OptionConstants.OUT); final CommandLineParser parser = new DefaultParser(); final CommandLine line = parser.parse(options, args); final File projectFolder = new File(line.getOptionValue(OptionConstants.FOLDER.getName())); final File dependencyFile; if (line.hasOption(OptionConstants.OUT.getName())) { dependencyFile = new File(line.getOptionValue(OptionConstants.OUT.getName())); } else {//from www . ja v a2 s. c o m dependencyFile = new File("dependencies.xml"); } File outputFile = projectFolder.getParentFile(); if (outputFile.isDirectory()) { outputFile = new File(projectFolder.getParentFile(), "ausgabe.txt"); } LOG.debug("Lese {}", projectFolder.getAbsolutePath()); final VersionControlSystem vcs = VersionControlSystem.getVersionControlSystem(projectFolder); System.setOut(new PrintStream(outputFile)); // System.setErr(new PrintStream(outputFile)); final DependencyReader reader; if (vcs.equals(VersionControlSystem.SVN)) { final String url = SVNUtils.getInstance().getWCURL(projectFolder); final List<SVNLogEntry> entries = getSVNCommits(line, url); LOG.debug("SVN commits: " + entries.stream().map(entry -> entry.getRevision()).collect(Collectors.toList())); reader = new DependencyReader(projectFolder, url, dependencyFile, entries); } else if (vcs.equals(VersionControlSystem.GIT)) { final List<GitCommit> commits = getGitCommits(line, projectFolder); reader = new DependencyReader(projectFolder, dependencyFile, commits); LOG.debug("Reader initalized"); } else { throw new RuntimeException("Unknown version control system"); } reader.readDependencies(); }
From source file:com.teradata.benchto.driver.DriverApp.java
public static void main(String[] args) throws Exception { CommandLine commandLine = processArguments(args); SpringApplicationBuilder applicationBuilder = new SpringApplicationBuilder(DriverApp.class).web(false) .properties();/*from w w w. jav a 2s . c o m*/ if (commandLine.hasOption("profile")) { applicationBuilder.profiles(commandLine.getOptionValue("profile")); } ConfigurableApplicationContext ctx = applicationBuilder.run(); ExecutionDriver executionDriver = ctx.getBean(ExecutionDriver.class); Thread.currentThread().setName("main"); try { executionDriver.execute(); System.exit(0); } catch (Throwable e) { logException(e); System.exit(1); } }
From source file:eu.scape_project.pc.tika.cli.TifowaCli.java
public static void main(String[] args) { // Static for command line option parsing TifowaCli tc = new TifowaCli(); detector = new DefaultDetector(); CommandLineParser cmdParser = new PosixParser(); try {// ww w.j a v a 2 s . co m CommandLine cmd = cmdParser.parse(OPTIONS, args); if ((args.length == 0) || (cmd.hasOption(HELP_OPT))) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Constants.USAGE, OPTIONS, true); System.exit(0); } else { if (cmd.hasOption(DIR_OPT) && cmd.getOptionValue(DIR_OPT) != null) { String dirStr = cmd.getOptionValue(DIR_OPT); logger.info("Directory: " + dirStr); // *** start timer long startClock = System.currentTimeMillis(); tc.processFiles(new File(dirStr)); // *** stop timer long elapsedTimeMillis = System.currentTimeMillis() - startClock; // *** display the TYPE collection displayMyTypes(myCollection, countAllCalls, countAllGoodItems, countAllFailedItems, elapsedTimeMillis); } else { logger.error("No directory given."); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Constants.USAGE, OPTIONS, true); System.exit(1); } } } catch (ParseException ex) { logger.error("Problem parsing command line arguments.", ex); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(Constants.USAGE, OPTIONS, true); System.exit(1); } }
From source file:di.uniba.it.tee2.shell.TEEShell.java
/** * language maindir encoding//w w w. j a va 2s . co m * * @param args the command line arguments */ public static void main(String[] args) { try { CommandLine cmd = cmdParser.parse(options, args); if (cmd.hasOption("l") && cmd.hasOption("d")) { TEEShell shell = new TEEShell(cmd.getOptionValue("l"), cmd.getOptionValue("d"), cmd.getOptionValue("e", DEFAULT_CHARSET)); shell.promptLoop(); } else { HelpFormatter helpFormatter = new HelpFormatter(); helpFormatter.printHelp("Run TEE2 shell", options, true); } } catch (ParseException | IOException ex) { Logger.getLogger(TEEShell.class.getName()).log(Level.SEVERE, "General error", ex); } }
From source file:io.druid.server.sql.SQLRunner.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption("h", "help", false, "help"); options.addOption("v", false, "verbose"); options.addOption("e", "host", true, "endpoint [hostname:port]"); CommandLine cmd = new GnuParser().parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("SQLRunner", options); System.exit(2);// w w w .jav a2 s . co m } String hostname = cmd.getOptionValue("e", "localhost:8080"); String sql = cmd.getArgs().length > 0 ? cmd.getArgs()[0] : STATEMENT; ObjectMapper objectMapper = new DefaultObjectMapper(); ObjectWriter jsonWriter = objectMapper.writerWithDefaultPrettyPrinter(); CharStream stream = new ANTLRInputStream(sql); DruidSQLLexer lexer = new DruidSQLLexer(stream); TokenStream tokenStream = new CommonTokenStream(lexer); DruidSQLParser parser = new DruidSQLParser(tokenStream); lexer.removeErrorListeners(); parser.removeErrorListeners(); lexer.addErrorListener(ConsoleErrorListener.INSTANCE); parser.addErrorListener(ConsoleErrorListener.INSTANCE); try { DruidSQLParser.QueryContext queryContext = parser.query(); if (parser.getNumberOfSyntaxErrors() > 0) throw new IllegalStateException(); // parser.setBuildParseTree(true); // System.err.println(q.toStringTree(parser)); } catch (Exception e) { String msg = e.getMessage(); if (msg != null) System.err.println(e); System.exit(1); } final Query query; final TypeReference typeRef; boolean groupBy = false; if (parser.groupByDimensions.isEmpty()) { query = Druids.newTimeseriesQueryBuilder().dataSource(parser.getDataSource()) .aggregators(new ArrayList<AggregatorFactory>(parser.aggregators.values())) .postAggregators(parser.postAggregators).intervals(parser.intervals) .granularity(parser.granularity).filters(parser.filter).build(); typeRef = new TypeReference<List<Result<TimeseriesResultValue>>>() { }; } else { query = GroupByQuery.builder().setDataSource(parser.getDataSource()) .setAggregatorSpecs(new ArrayList<AggregatorFactory>(parser.aggregators.values())) .setPostAggregatorSpecs(parser.postAggregators).setInterval(parser.intervals) .setGranularity(parser.granularity).setDimFilter(parser.filter) .setDimensions(new ArrayList<DimensionSpec>(parser.groupByDimensions.values())).build(); typeRef = new TypeReference<List<Row>>() { }; groupBy = true; } String queryStr = jsonWriter.writeValueAsString(query); if (cmd.hasOption("v")) System.err.println(queryStr); URL url = new URL(String.format("http://%s/druid/v2/?pretty", hostname)); final URLConnection urlConnection = url.openConnection(); urlConnection.addRequestProperty("content-type", MediaType.APPLICATION_JSON); urlConnection.getOutputStream().write(StringUtils.toUtf8(queryStr)); BufferedReader stdInput = new BufferedReader( new InputStreamReader(urlConnection.getInputStream(), Charsets.UTF_8)); Object res = objectMapper.readValue(stdInput, typeRef); Joiner tabJoiner = Joiner.on("\t"); if (groupBy) { List<Row> rows = (List<Row>) res; Iterable<String> dimensions = Iterables.transform(parser.groupByDimensions.values(), new Function<DimensionSpec, String>() { @Override public String apply(@Nullable DimensionSpec input) { return input.getOutputName(); } }); System.out.println( tabJoiner.join(Iterables.concat(Lists.newArrayList("timestamp"), dimensions, parser.fields))); for (final Row r : rows) { System.out.println(tabJoiner.join(Iterables.concat( Lists.newArrayList(parser.granularity.toDateTime(r.getTimestampFromEpoch())), Iterables.transform(parser.groupByDimensions.values(), new Function<DimensionSpec, String>() { @Override public String apply(@Nullable DimensionSpec input) { return Joiner.on(",").join(r.getDimension(input.getOutputName())); } }), Iterables.transform(parser.fields, new Function<String, Object>() { @Override public Object apply(@Nullable String input) { return r.getFloatMetric(input); } })))); } } else { List<Result<TimeseriesResultValue>> rows = (List<Result<TimeseriesResultValue>>) res; System.out.println(tabJoiner.join(Iterables.concat(Lists.newArrayList("timestamp"), parser.fields))); for (final Result<TimeseriesResultValue> r : rows) { System.out.println(tabJoiner.join(Iterables.concat(Lists.newArrayList(r.getTimestamp()), Lists.transform(parser.fields, new Function<String, Object>() { @Override public Object apply(@Nullable String input) { return r.getValue().getMetric(input); } })))); } } CloseQuietly.close(stdInput); }
From source file:jrrombaldo.pset.PSETMain.java
public static void main(String[] args) { Options options = prepareOptions();/* ww w.ja v a 2 s . co m*/ CommandLineParser parser = new DefaultParser(); try { CommandLine line = parser.parse(options, args); String domain = line.getOptionValue("d"); // print help if (line.hasOption("h")) { printHelp(options); return; } // start gui e do nothing else if (!line.hasOption("c")) { startGuiVersion(domain); return; } // start gui e do nothing else if (!line.hasOption("d")) { System.out.println("a target domain is required, none was specified!"); printHelp(options); return; } if (!line.hasOption("g") && !line.hasOption("b")) { System.out.println("No search engine selected, at least one should be present"); printHelp(options); return; } if (line.hasOption("p")) { String proxy = line.getOptionValue("p"); System.out.println(proxy); } Set<String> results = new HashSet<>(); if (line.hasOption("g")) { results.addAll(new GoogleSearch(domain).listSubdomains()); } if (line.hasOption("b")) { results.addAll(new BingSearch(domain).listSubdomains()); } List<String> sortedResult = new ArrayList<String>(results); Collections.sort(sortedResult); int q = 1; for (String subDomain : sortedResult) { if (q == 1) { System.out.println("\nResults:"); } System.out.println(q + ": " + subDomain); q++; } } catch (ParseException exp) { System.out.println(exp.getLocalizedMessage()); printHelp(options); } catch (Exception e) { e.printStackTrace(); } }