List of usage examples for org.apache.commons.cli Options Options
Options
From source file:com.nextdoor.bender.ValidateSchema.java
public static void main(String[] args) throws ParseException, InterruptedException, IOException { /*/*from w ww .j a v a 2 s .c o m*/ * Parse cli arguments */ Options options = new Options(); options.addOption(Option.builder().longOpt("schema").hasArg() .desc("Filename to output schema to. Default: schema.json").build()); options.addOption(Option.builder().longOpt("configs").hasArgs() .desc("List of config files to validate against schema.").build()); CommandLineParser parser = new DefaultParser(); CommandLine cmd = parser.parse(options, args); String schemaFilename = cmd.getOptionValue("schema", "schema.json"); String[] configFilenames = cmd.getOptionValues("configs"); /* * Validate config files against schema */ boolean hasFailures = false; for (String configFilename : configFilenames) { StringBuilder sb = new StringBuilder(); Files.lines(Paths.get(configFilename), StandardCharsets.UTF_8).forEach(p -> sb.append(p + "\n")); System.out.println("Attempting to validate " + configFilename); try { ObjectMapper mapper = BenderConfig.getObjectMapper(configFilename); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.CAMEL_CASE_TO_LOWER_CASE_WITH_UNDERSCORES); BenderConfig.load(configFilename, sb.toString(), mapper, true); System.out.println("Valid"); BenderConfig config = BenderConfig.load(configFilename, sb.toString()); } catch (ConfigurationException e) { System.out.println("Invalid"); e.printStackTrace(); hasFailures = true; } } if (hasFailures) { System.exit(1); } }
From source file:cc.twittertools.index.ExtractTweetidsFromIndex.java
@SuppressWarnings("static-access") public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(//from w w w . j ava 2s . c o m OptionBuilder.withArgName("dir").hasArg().withDescription("index location").create(INDEX_OPTION)); CommandLine cmdline = null; CommandLineParser parser = new GnuParser(); try { cmdline = parser.parse(options, args); } catch (ParseException exp) { System.err.println("Error parsing command line: " + exp.getMessage()); System.exit(-1); } if (!cmdline.hasOption(INDEX_OPTION)) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp(ExtractTweetidsFromIndex.class.getName(), options); System.exit(-1); } File indexLocation = new File(cmdline.getOptionValue(INDEX_OPTION)); if (!indexLocation.exists()) { System.err.println("Error: " + indexLocation + " does not exist!"); System.exit(-1); } IndexReader reader = DirectoryReader.open(FSDirectory.open(indexLocation)); PrintStream out = new PrintStream(System.out, true, "UTF-8"); for (int i = 0; i < reader.maxDoc(); i++) { Document doc = reader.document(i); out.println(doc.getField(StatusField.ID.name).stringValue() + "\t" + doc.getField(StatusField.SCREEN_NAME.name).stringValue()); } out.close(); reader.close(); }
From source file:com.hortonworks.registries.storage.tool.shell.ShellMigrationInitializer.java
public static void main(String[] args) throws Exception { Options options = new Options(); options.addOption(Option.builder("s").numberOfArgs(1).longOpt(OPTION_SCRIPT_ROOT_PATH) .desc("Root directory of script path").build()); options.addOption(Option.builder("c").numberOfArgs(1).longOpt(OPTION_CONFIG_FILE_PATH) .desc("Config file path").build()); options.addOption(Option.builder().hasArg(false).longOpt(ShellMigrationOption.MIGRATE.toString()) .desc("Execute schema migration from last check point").build()); options.addOption(Option.builder().hasArg(false).longOpt(ShellMigrationOption.INFO.toString()) .desc("Show the status of the schema migration compared to the target database").build()); options.addOption(Option.builder().hasArg(false).longOpt(ShellMigrationOption.VALIDATE.toString()) .desc("Validate the target database changes with the migration scripts").build()); options.addOption(Option.builder().hasArg(false).longOpt(ShellMigrationOption.REPAIR.toString()).desc( "Repairs the SCRIPT_CHANGE_LOG by removing failed migrations and correcting checksum of existing migration script") .build());/*from w w w . jav a2 s .c o m*/ CommandLineParser parser = new BasicParser(); CommandLine commandLine = parser.parse(options, args); if (!commandLine.hasOption(OPTION_SCRIPT_ROOT_PATH)) { usage(options); System.exit(1); } boolean isShellMigrationOptionSpecified = false; ShellMigrationOption shellMigrationOptionSpecified = null; for (ShellMigrationOption shellMigrationOption : ShellMigrationOption.values()) { if (commandLine.hasOption(shellMigrationOption.toString())) { if (isShellMigrationOptionSpecified) { System.out.println( "Only one operation can be execute at once, please select one of ',migrate', 'validate', 'info', 'repair'."); System.exit(1); } isShellMigrationOptionSpecified = true; shellMigrationOptionSpecified = shellMigrationOption; } } if (!isShellMigrationOptionSpecified) { System.out.println( "One of the option 'migrate', 'validate', 'info', 'repair' must be specified to execute."); System.exit(1); } String scriptRootPath = commandLine.getOptionValue(OPTION_SCRIPT_ROOT_PATH); String confFilePath = commandLine.getOptionValue(OPTION_CONFIG_FILE_PATH); StorageProviderConfiguration storageProperties; try { Map<String, Object> conf = Utils.readConfig(confFilePath); StorageProviderConfigurationReader confReader = new StorageProviderConfigurationReader(); storageProperties = confReader.readStorageConfig(conf); } catch (IOException e) { System.err.println("Error occurred while reading config file: " + confFilePath); System.exit(1); throw new IllegalStateException("Shouldn't reach here"); } ShellMigrationHelper schemaMigrationHelper = new ShellMigrationHelper( ShellFlywayFactory.get(storageProperties, scriptRootPath)); try { schemaMigrationHelper.execute(shellMigrationOptionSpecified); System.out.println(String.format("\"%s\" option successful", shellMigrationOptionSpecified.toString())); } catch (Exception e) { System.err.println(String.format("\"%s\" option failed : %s", shellMigrationOptionSpecified.toString(), e.getMessage())); System.exit(1); } }
From source file:fr.cnrs.sharp.Main.java
public static void main(String args[]) { Options options = new Options(); Option versionOpt = new Option("v", "version", false, "print the version information and exit"); Option helpOpt = new Option("h", "help", false, "print the help"); Option inProvFileOpt = OptionBuilder.withArgName("input_PROV_file_1> ... <input_PROV_file_n") .withLongOpt("input_PROV_files").withDescription("The list of PROV input files, in RDF Turtle.") .hasArgs().create("i"); Option inRawFileOpt = OptionBuilder.withArgName("input_raw_file_1> ... <input_raw_file_n") .withLongOpt("input_raw_files") .withDescription(/* w w w . j a va 2s. c om*/ "The list of raw files to be fingerprinted and possibly interlinked with owl:sameAs.") .hasArgs().create("ri"); Option summaryOpt = OptionBuilder.withArgName("summary").withLongOpt("summary") .withDescription("Materialization of wasInfluencedBy relations.").create("s"); options.addOption(inProvFileOpt); options.addOption(inRawFileOpt); options.addOption(versionOpt); options.addOption(helpOpt); options.addOption(summaryOpt); String header = "SharpTB is a tool to maturate provenance based on PROV inferences"; String footer = "\nPlease report any issue to alban.gaignard@univ-nantes.fr"; try { CommandLineParser parser = new BasicParser(); CommandLine cmd = parser.parse(options, args); if (cmd.hasOption("h")) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("SharpTB", header, options, footer, true); System.exit(0); } if (cmd.hasOption("v")) { logger.info("SharpTB version 0.1.0"); System.exit(0); } if (cmd.hasOption("ri")) { String[] inFiles = cmd.getOptionValues("ri"); Model model = ModelFactory.createDefaultModel(); for (String inFile : inFiles) { Path p = Paths.get(inFile); if (!p.toFile().isFile()) { logger.error("Cannot find file " + inFile); System.exit(1); } else { //1. fingerprint try { model.add(Interlinking.fingerprint(p)); } catch (IOException e) { logger.error("Cannot fingerprint file " + inFile); } } } //2. genSameAs Model sameAs = Interlinking.generateSameAs(model); sameAs.write(System.out, "TTL"); } if (cmd.hasOption("i")) { String[] inFiles = cmd.getOptionValues("i"); Model data = ModelFactory.createDefaultModel(); for (String inFile : inFiles) { Path p = Paths.get(inFile); if (!p.toFile().isFile()) { logger.error("Cannot find file " + inFile); System.exit(1); } else { RDFDataMgr.read(data, inFile, Lang.TTL); } } Model res = Harmonization.harmonizeProv(data); try { Path pathInfProv = Files.createTempFile("PROV-inf-tgd-egd-", ".ttl"); res.write(new FileWriter(pathInfProv.toFile()), "TTL"); System.out.println("Harmonized PROV written to file " + pathInfProv.toString()); //if the summary option is activated, then save the subgraph and generate a visualization if (cmd.hasOption("s")) { String queryInfluence = "PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> \n" + "PREFIX prov: <http://www.w3.org/ns/prov#> \n" + "CONSTRUCT { \n" + " ?x ?p ?y .\n" + " ?x rdfs:label ?lx .\n" + " ?y rdfs:label ?ly .\n" + "} WHERE {\n" + " ?x ?p ?y .\n" + " FILTER (?p IN (prov:wasInfluencedBy)) .\n" + " ?x rdfs:label ?lx .\n" + " ?y rdfs:label ?ly .\n" + "}"; Query query = QueryFactory.create(queryInfluence); QueryExecution queryExec = QueryExecutionFactory.create(query, res); Model summary = queryExec.execConstruct(); queryExec.close(); Util.writeHtmlViz(summary); } } catch (IOException ex) { logger.error("Impossible to write the harmonized provenance file."); System.exit(1); } } else { // logger.info("Please fill the -i input parameter."); // HelpFormatter formatter = new HelpFormatter(); // formatter.printHelp("SharpTB", header, options, footer, true); // System.exit(0); } } catch (ParseException ex) { logger.error("Error while parsing command line arguments. Please check the following help:"); HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("SharpToolBox", header, options, footer, true); System.exit(1); } }
From source file:edu.cmu.lti.oaqa.bio.index.medline.annotated.query.SimpleQueryApp.java
public static void main(String[] args) { Options options = new Options(); options.addOption("u", null, true, "Solr URI"); options.addOption("n", null, true, "Max # of results"); CommandLineParser parser = new org.apache.commons.cli.GnuParser(); try {//from w ww . j a va 2 s. c o m CommandLine cmd = parser.parse(options, args); String solrURI = null; solrURI = cmd.getOptionValue("u"); if (solrURI == null) { Usage("Specify Solr URI"); } SolrServerWrapper solr = new SolrServerWrapper(solrURI); int numRet = 10; if (cmd.hasOption("n")) { numRet = Integer.parseInt(cmd.getOptionValue("n")); } List<String> fieldList = new ArrayList<String>(); fieldList.add(UtilConstMedline.ID_FIELD); fieldList.add(UtilConstMedline.SCORE_FIELD); fieldList.add(UtilConstMedline.ARTICLE_TITLE_FIELD); fieldList.add(UtilConstMedline.ENTITIES_DESC_FIELD); fieldList.add(UtilConstMedline.ABSTRACT_TEXT_FIELD); BufferedReader sysInReader = new BufferedReader(new InputStreamReader(System.in)); Joiner commaJoiner = Joiner.on(','); while (true) { System.out.println("Input query: "); String query = sysInReader.readLine(); if (null == query) break; QueryTransformer qt = new QueryTransformer(query); String tranQuery = qt.getQuery(); System.out.println("Translated query:"); System.out.println(tranQuery); System.out.println("========================="); SolrDocumentList res = solr.runQuery(tranQuery, fieldList, numRet); System.out.println("Found " + res.getNumFound() + " entries"); for (SolrDocument doc : res) { String id = (String) doc.getFieldValue(UtilConstMedline.ID_FIELD); float score = (Float) doc.getFieldValue(UtilConstMedline.SCORE_FIELD); String title = (String) doc.getFieldValue(UtilConstMedline.ARTICLE_TITLE_FIELD); String titleAbstract = (String) doc.getFieldValue(UtilConstMedline.ABSTRACT_TEXT_FIELD); System.out.println(score + " PMID=" + id + " " + titleAbstract); String entityDesc = (String) doc.getFieldValue(UtilConstMedline.ENTITIES_DESC_FIELD); System.out.println("Entities:"); for (EntityEntry e : EntityEntry.parseEntityDesc(entityDesc)) { System.out.println(String.format("[%d %d] concept=%s concept_ids=%s", e.mStart, e.mEnd, e.mConcept, commaJoiner.join(e.mConceptIds))); } } } solr.close(); } catch (ParseException e) { Usage("Cannot parse arguments"); } catch (Exception e) { System.err.println("Terminating due to an exception: " + e); System.exit(1); } }
From source file:io.rhiot.spec.IoTSpec.java
public static void main(String[] args) throws Exception { CommandLineParser parser = new DefaultParser(); Options options = new Options(); options.addOption(Option.builder("c").longOpt(CONFIG).desc( "Location of the test configuration file. A default value is 'src/main/resources/test.yaml' for easy IDE testing") .hasArg().build());/*from w ww .ja va2 s. c om*/ options.addOption(Option.builder("i").longOpt(INSTANCE).desc("Instance of the test; A default value is 1") .hasArg().build()); options.addOption(Option.builder("r").longOpt(REPORT) .desc("Location of the test report. A default value is 'target/report.csv'").hasArg().build()); CommandLine line = parser.parse(options, args); ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); TestProfile test = mapper.readValue(new File(line.getOptionValue(CONFIG, "src/main/resources/test.yaml")), TestProfile.class); int instance = Integer.valueOf(line.getOptionValue(INSTANCE, "1")); test.setInstance(instance); String report = line.getOptionValue(REPORT, "target/report.csv"); test.setReport(new CSVReport(report)); LOG.info("Test '" + test.getName() + "' instance " + instance + " started"); final List<Driver> drivers = test.getDrivers(); ExecutorService executorService = Executors.newFixedThreadPool(drivers.size()); List<Future<Void>> results = executorService.invokeAll(drivers, test.getDuration(), TimeUnit.MILLISECONDS); executorService.shutdownNow(); executorService.awaitTermination(5, TimeUnit.SECONDS); results.forEach(result -> { try { result.get(); } catch (ExecutionException execution) { LOG.warn("Exception running driver", execution); } catch (Exception interrupted) { } }); drivers.forEach(driver -> { driver.stop(); try { test.getReport().print(driver); } catch (Exception e) { LOG.warn("Failed to write reports for the driver " + driver); } LOG.debug("Driver " + driver); LOG.debug("\t " + driver.getResult()); }); test.getReport().close(); LOG.info("Test '" + test.getName() + "' instance " + instance + " finished"); }
From source file:Pong.java
public static void main(String... args) throws Exception { System.setProperty("os.max.pid.bits", "16"); Options options = new Options(); options.addOption("i", true, "Input chronicle path"); options.addOption("n", true, "Number of entries to write"); options.addOption("w", true, "Number of writer threads"); options.addOption("r", true, "Number of reader threads"); options.addOption("x", false, "Delete the output chronicle at startup"); CommandLine cmd = new DefaultParser().parse(options, args); final Path output = Paths.get(cmd.getOptionValue("o", "/tmp/__test/chr")); final long maxCount = Long.parseLong(cmd.getOptionValue("n", "10000000")); final int writerThreadCount = Integer.parseInt(cmd.getOptionValue("w", "4")); final int readerThreadCount = Integer.parseInt(cmd.getOptionValue("r", "4")); final boolean deleteOnStartup = cmd.hasOption("x"); if (deleteOnStartup) { FileUtil.removeRecursive(output); }/*from w ww . j a v a 2 s. c o m*/ final Chronicle chr = ChronicleQueueBuilder.vanilla(output.toFile()).build(); final ExecutorService executor = Executors.newFixedThreadPool(4); final List<Future<?>> futures = new ArrayList<>(); final long totalCount = writerThreadCount * maxCount; final long t0 = System.nanoTime(); for (int i = 0; i != readerThreadCount; ++i) { final int tid = i; futures.add(executor.submit((Runnable) () -> { try { IntLongMap counts = HashIntLongMaps.newMutableMap(); ExcerptTailer tailer = chr.createTailer(); final StringBuilder sb1 = new StringBuilder(); final StringBuilder sb2 = new StringBuilder(); long count = 0; while (count != totalCount) { if (!tailer.nextIndex()) continue; final int id = tailer.readInt(); final long val = tailer.readStopBit(); final long longValue = tailer.readLong(); sb1.setLength(0); sb2.setLength(0); tailer.read8bitText(sb1); tailer.read8bitText(sb2); if (counts.addValue(id, 1) - 1 != val || longValue != 0x0badcafedeadbeefL || !StringInterner.isEqual("FooBar", sb1) || !StringInterner.isEqual("AnotherFooBar", sb2)) { System.out.println("Unexpected value " + id + ", " + val + ", " + Long.toHexString(longValue) + ", " + sb1.toString() + ", " + sb2.toString()); return; } ++count; if (count % 1_000_000 == 0) { long t1 = System.nanoTime(); System.out.println(tid + " " + (t1 - t0) / 1e6 + " ms"); } } } catch (IOException e) { e.printStackTrace(); } })); } for (Future f : futures) { f.get(); } executor.shutdownNow(); final long t1 = System.nanoTime(); System.out.println("Done. Rough time=" + (t1 - t0) / 1e6 + " ms"); }
From source file:com.aguin.stock.recommender.UserOptions.java
public static void main(String[] args) { options = new Options(); Option optU = OptionBuilder.hasArg().withArgName("uid").isRequired(true).withType(String.class) .withDescription(/*from w w w .j a va2s .c om*/ "User ID : must be a valid email address which serves as the unique identity of the portfolio") .create("u"); Option optI = OptionBuilder.hasOptionalArgs().withArgName("item").withType(String.class).isRequired(false) .withDescription( "Stock(s) in your portfolio: Print all stocks selected by this option and preferences against them") .create("i"); Option optP = OptionBuilder.hasOptionalArgs().withArgName("pref").isRequired(false).withType(Long.class) .withDescription( "Preference(s) against stocks in portfolio : Print all preferences specified in option and all stocks listed against that preference. Multiple preferences may be specified to draw on the many-many relationship between stocks and preferences matrices") .create("p"); Option optIP = OptionBuilder.hasArg().withArgName("itempref").withValueSeparator(':').isRequired(false) .withDescription( "Enter stock and preferences over command line. Any new stock will be registered as a new entry along with preference. Each new preference for an already existing stock will overwrite the existing preference(so be careful!)") .create("ip"); Option optF = OptionBuilder.hasArg().withArgName("itempreffile").withType(String.class) .withDescription("File to read stock preference data from").isRequired(false).create("f"); Option optH = OptionBuilder.hasArg(false).withArgName("help").withType(String.class) .withDescription("Display usage").isRequired(false).create("h"); options.addOption(optU); options.addOption(optI); options.addOption(optP); options.addOption(optIP); options.addOption(optF); options.addOption(optH); parser = new BasicParser(); CommandLine line = null; try { line = parser.parse(options, args); } catch (MissingOptionException e) { System.out.println("Missing options"); printUsage(); } catch (ParseException e) { e.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } if (line.hasOption("help")) { printUsage(); } UserArgumentEmailType uEmailId = new UserArgumentEmailType(line.getOptionValue("u")); String uEmailIdStr = uEmailId.toString(); if (MongoDBUserModel.registered(uEmailIdStr)) { System.out.format("Already registered user %s\n", uEmailIdStr); } else { System.out.format("+--Starting transaction for user %s --+\n", uEmailIdStr); } if (line.hasOption("f")) { System.out.println("Query::UpdateDB: itempreffile(s)\n"); String[] uItemPrefFiles = line.getOptionValues("f"); for (String it : uItemPrefFiles) { System.out.format("Updating db with user file %s\n", it); UserItemPrefFile uItemPrefFile = new UserItemPrefFile(uEmailIdStr, it); uItemPrefFile.writeToDB(); } } if (line.hasOption("i")) { System.out.println("Query::ReadDB: item(s)\n"); String[] uItems = line.getOptionValues("i"); for (String it : uItems) { System.out.format("Searching for item %s in db\n", it); UserItem uItem = new UserItem(uEmailIdStr, it); uItem.readFromDB(); } } if (line.hasOption("p")) { System.out.println("Query::ReadDB: preference(s)"); String[] uPrefs = line.getOptionValues("p"); for (String it : uPrefs) { System.out.format("Searching for preference %s in db\n", it); UserPreference uPref = new UserPreference(uEmailIdStr, it); uPref.readFromDB(); } } if (line.hasOption("ip")) { System.out.println("Query::UpdateDB: itempref(s)\n"); String[] uItemPrefs = line.getOptionValues("ip"); for (String it : uItemPrefs) { System.out.format("Updating item:preference pair %s\n", it); String[] pair = it.split(":"); System.out.format("%s:%s:%s", uEmailIdStr, pair[0], pair[1]); UserItemPreference uItemPref = new UserItemPreference(uEmailIdStr, pair[0], pair[1]); uItemPref.writeToDB(); } } System.out.format("+-- Ending transaction for user %s --+\n", uEmailIdStr); }
From source file:com.google.cloud.logging.v2.LoggingSmokeTest.java
public static void main(String args[]) { Logger.getLogger("").setLevel(Level.WARNING); try {//from ww w .ja v a 2 s. c o m Options options = new Options(); options.addOption("h", "help", false, "show usage"); options.addOption(Option.builder().longOpt("project_id").desc("Project id").hasArg() .argName("PROJECT-ID").required(true).build()); CommandLine cl = (new DefaultParser()).parse(options, args); if (cl.hasOption("help")) { HelpFormatter formater = new HelpFormatter(); formater.printHelp("LoggingSmokeTest", options); } executeNoCatch(cl.getOptionValue("project_id")); System.out.println("OK"); } catch (Exception e) { System.err.println("Failed with exception:"); e.printStackTrace(System.err); System.exit(1); } }
From source file:com.happy_coding.viralo.coordinator.ViraloRunner.java
/** * Main task.// ww w . j av a 2s . c o m * * @param args * @throws Exception */ public static void main(String[] args) throws Exception { // Parser CommandLineParser parser = new PosixParser(); // Options Options options = new Options(); Option createFriends = OptionBuilder.withDescription("Create friends by using the given keywords.").hasArg() .withArgName("keywords").create("createFriends"); options.addOption(createFriends); options.addOption("R", "refreshFollowers", false, "refresh followers for current user."); options.addOption("C", "cleanup", false, "delete friends which don't follow"); options.addOption("S", "smartTweet", false, "Posts a smart tweet."); options.addOption("F", "createTrendFriends", false, "Create friends to a random trend."); options.addOption("T", "answerTopQuestion", false, "answer a top question and post it."); options.addOption("RC", "robotConversation", false, "starts a task which answers mentions automatically."); if (args.length < 1) { HelpFormatter formatter = new HelpFormatter(); formatter.printHelp("java -jar ...jar", options); System.exit(0); } CommandLine line = parser.parse(options, args); if (line.hasOption("createFriends")) { String keywords = line.getOptionValue("createFriends"); Viralo viralo = new Viralo(); FriendDiscoverer friendDiscoverer = new FriendDiscoverer(); Contact forContact = friendDiscoverer.returnMyself(); System.out.println("Create friends for " + forContact.getName()); viralo.createNewFriends(forContact, keywords, ";"); } else if (line.hasOption("refreshFollowers")) { Viralo viralo = new Viralo(); FriendDiscoverer friendDiscoverer = new FriendDiscoverer(); Contact forContact = friendDiscoverer.returnMyself(); viralo.refreshFollowers(forContact); } else if (line.hasOption("cleanup")) { Viralo viralo = new Viralo(); FriendDiscoverer friendDiscoverer = new FriendDiscoverer(); Contact forContact = friendDiscoverer.returnMyself(); viralo.cleanup(forContact); } else if (line.hasOption("smartTweet")) { Viralo viralo = new Viralo(); viralo.postSmartTweet(); } else if (line.hasOption("createTrendFriends")) { FriendDiscoverer friendDiscoverer = new FriendDiscoverer(); Contact forContact = friendDiscoverer.returnMyself(); Viralo viralo = new Viralo(); viralo.createNewFriends(forContact); } else if (line.hasOption("answerTopQuestion")) { Viralo viralo = new Viralo(); viralo.answerTopQuestion(); } else if (line.hasOption("robotConversation")) { boolean taskFlag = true; Viralo viralo = new Viralo(); while (taskFlag) { /* reply to mentions */ viralo.autoConversation(); /* wait some seconds. */ Thread.sleep(WAIT_MS_BETWEEN_ACTIONS); } } System.exit(0); }