Example usage for org.apache.commons.cli ParseException getMessage

List of usage examples for org.apache.commons.cli ParseException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.cli ParseException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:com.soulgalore.crawler.run.CrawlAndVerifyAssetsToCsv.java

/**
 * Run./*w w  w .  j  av a2s  .  c o  m*/
 * 
 * @param args the args
 */
public static void main(String[] args) {

    try {
        final CrawlAndVerifyAssetsToCsv crawl = new CrawlAndVerifyAssetsToCsv(args);
        crawl.crawl();

    } catch (ParseException e) {
        System.err.print(e.getMessage());
    } catch (IllegalArgumentException e) {
        System.err.println(e.getMessage());
    }

}

From source file:com.github.houbie.lesscss.Lessc.java

public static void main(String[] args) throws Exception {
    LesscCommandLineParser lesscCommandLineParser = new LesscCommandLineParser(getVersionInfo());
    try {//from w  ww  .jav a2s . c  o  m
        boolean done = lesscCommandLineParser.parse(args);

        if (!done) {
            execute(lesscCommandLineParser);
        }
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        LesscCommandLineParser.printHelp();
    }
}

From source file:edu.usc.pgroup.floe.client.commands.KillApp.java

/**
 * Entry point for Scale command.//from w w w .j  av  a  2  s .  c  o  m
 * @param args command line arguments sent by the floe.py script.
 */
public static void main(final String[] args) {

    Options options = new Options();

    Option appOption = OptionBuilder.withArgName("name").hasArg().isRequired()
            .withDescription("Application Name").create("app");

    options.addOption(appOption);

    CommandLineParser parser = new BasicParser();
    CommandLine line;

    try {
        line = parser.parse(options, args);

    } catch (ParseException e) {
        LOGGER.error("Invalid command: " + e.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("scale options", options);
        return;
    }

    String app = line.getOptionValue("app");

    LOGGER.info("Application: {}", app);

    try {
        FloeClient.getInstance().killApp(app);
    } catch (TException e) {
        LOGGER.error("Error while connecting to the coordinator: {}", e);
    }
}

From source file:io.github.the28awg.okato.App.java

public static void main(String[] args) {
    Options options = new Options();

    options.addOption(Option.builder().longOpt("token").hasArg().required().argName("token")
            .desc(" ? ?  ??").build());
    options.addOption(Option.builder("t").longOpt("type").hasArg().required().argName("type")
            .desc("  [city, street, building]").build());
    options.addOption(Option.builder("q").longOpt("query").hasArg().argName("query")
            .desc(" ? ?  ").build());
    options.addOption(Option.builder("c").longOpt("city_id").hasArg().argName("city_id")
            .desc("  (? )").build());
    options.addOption(Option.builder("s").longOpt("street_id").hasArg().argName("street_id")
            .desc(" ").build());

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;/* w w w  .ja va 2 s .com*/

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("okato", options);
        System.exit(1);
        return;
    }

    AddressFactory.token(cmd.getOptionValue("token"));

    String arg_type = cmd.getOptionValue("type");
    String arg_city_id = cmd.getOptionValue("city_id", "");
    String arg_street_id = cmd.getOptionValue("street_id", "");
    String arg_query = cmd.getOptionValue("query", "");
    if (arg_type.equalsIgnoreCase("city")) {
        try {
            log(SimpleOkato.toSimpleResponse(
                    AddressFactory.service().city(AddressFactory.token(), arg_query).execute().body()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (arg_type.equalsIgnoreCase("street")) {
        try {
            log(SimpleOkato.toSimpleResponse(AddressFactory.service()
                    .street(AddressFactory.token(), arg_city_id, arg_query).execute().body()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    } else if (arg_type.equalsIgnoreCase("building")) {
        try {
            log(SimpleOkato.toSimpleResponse(AddressFactory.service()
                    .building(AddressFactory.token(), arg_city_id, arg_street_id, arg_query).execute().body()));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}

From source file:jlite.cli.ProxyDestroy.java

public static void main(String[] args) {
    System.out.println(); // extra line
    CommandLineParser parser = new GnuParser();
    Options options = setupOptions();//from  ww w.  j  a  v a  2 s .c om
    HelpFormatter helpFormatter = new HelpFormatter();
    helpFormatter.setSyntaxPrefix("Usage: ");
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
        if (line.hasOption("help")) {
            helpFormatter.printHelp(100, COMMAND, "\noptions:", options, "\n" + CLI.FOOTER, false);
            System.out.println(); // extra line
            System.exit(0);
        }

        if (line.hasOption("xml")) {
            System.out.println("<output>");
        }

        run(line);
    } catch (ParseException e) {
        System.err.println(e.getMessage() + "\n");
        helpFormatter.printHelp(100, COMMAND, "\noptions:", options, "\n" + CLI.FOOTER, false);
        System.out.println(); // extra line
        System.exit(-1);
    } catch (Exception e) {
        if (line.hasOption("xml")) {
            System.out.println("<error>" + e.getMessage() + "</error>");
        } else {
            System.err.println(e.getMessage());
        }
    } finally {
        System.out.println("</output>");
    }
    System.out.println(); // extra line
}

From source file:com.opengamma.bbg.replay.BloombergTicksCollectorLauncher.java

/**
 * Starts the Bloomberg Ticks Collector.
 * //from w w  w  .  ja v  a 2 s.  c o  m
 * @param args Not needed
 */
public static void main(String[] args) { // CSIGNORE

    int duration = 0;
    CommandLineParser parser = new PosixParser();
    Options options = new Options();
    options.addOption("d", "duration", true, "minutes to run");
    try {
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("duration")) {
            duration = Integer.parseInt(cmd.getOptionValue("duration"));
        }
    } catch (ParseException exp) {
        s_logger.error("Option parsing failed: {}", exp.getMessage());
        return;
    }

    BloombergTicksCollectorLauncher launcher = new BloombergTicksCollectorLauncher();
    launcher.run();
    if (duration > 0) {
        try {
            Thread.sleep(duration * 60 * 1000);
        } catch (InterruptedException e) {
        }
        launcher.exit();
    }
}

From source file:cc.twittertools.index.ExtractTweetidsFromCollection.java

@SuppressWarnings("static-access")
public static void main(String[] args) throws Exception {
    Options options = new Options();

    options.addOption(OptionBuilder.withArgName("dir").hasArg().withDescription("source collection directory")
            .create(COLLECTION_OPTION));

    CommandLine cmdline = null;/*from   www  .  ja  va 2 s.  c  om*/
    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(COLLECTION_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(ExtractTweetidsFromCollection.class.getName(), options);
        System.exit(-1);
    }

    String collectionPath = cmdline.getOptionValue(COLLECTION_OPTION);

    File file = new File(collectionPath);
    if (!file.exists()) {
        System.err.println("Error: " + file + " does not exist!");
        System.exit(-1);
    }

    StatusStream stream = new JsonStatusCorpusReader(file);

    Status status;
    while ((status = stream.next()) != null) {
        System.out.println(status.getId() + "\t" + status.getScreenname());
    }
}

From source file:com.ctriposs.rest4j.tools.snapshot.gen.Rest4JSnapshotExporterCmdLineApp.java

/**
 * @param args rest4jexporter -sourcepath sourcepath -resourcepackages packagenames [-name api_name] [-outdir outdir]
 *//*w  w  w . j  av a 2  s.  c o  m*/
public static void main(String[] args) {
    CommandLine cl = null;
    try {
        final CommandLineParser parser = new GnuParser();
        cl = parser.parse(OPTIONS, args);
    } catch (ParseException e) {
        System.err.println("Invalid arguments: " + e.getMessage());
        final HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(
                "rest4jexporter -sourcepath sourcepath [-resourcepackages packagenames] [-resourceclasses classnames]"
                        + "[-name api_name] [-outdir outdir]",
                OPTIONS);
        System.exit(0);
    }

    final String resolverPath = System.getProperty(AbstractGenerator.GENERATOR_RESOLVER_PATH);

    try {
        final Rest4JSnapshotExporter exporter = new Rest4JSnapshotExporter();
        exporter.setResolverPath(resolverPath);
        exporter.export(cl.getOptionValue("name"), null, cl.getOptionValues("sourcepath"),
                cl.getOptionValues("resourcepackages"), cl.getOptionValues("resourceClasses"),
                cl.getOptionValue("outdir", "."));
    } catch (Throwable e) {
        log.error("Error writing Snapshot files", e);
        System.out.println("Error writing Snapshot files:\n" + e);
        System.exit(1);
    }
}

From source file:info.bitoo.utils.BiToorrentRemaker.java

public static void main(String[] args) throws IOException, TOTorrentException {
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;//  w w w .  j  a v a  2 s. c om
    try {
        cmd = parser.parse(createCommandLineOptions(), args);
    } catch (ParseException e) {
        System.err.println("Parsing failed.  Reason: " + e.getMessage());
    }

    StringTokenizer stLocations = new StringTokenizer(cmd.getOptionValue("l"), "|");
    List locations = new ArrayList(stLocations.countTokens());

    while (stLocations.hasMoreTokens()) {
        URL locationURL = new URL((String) stLocations.nextToken());
        locations.add(locationURL.toString());
    }

    String torrentFileName = cmd.getOptionValue("t");

    File torrentFile = new File(torrentFileName);

    TOTorrentDeserialiseImpl torrent = new TOTorrentDeserialiseImpl(torrentFile);

    torrent.setAdditionalListProperty("alternative locations", locations);

    torrent.serialiseToBEncodedFile(torrentFile);

}

From source file:edu.mit.csail.sdg.alloy4.VizGUI.java

/**
 * @param args/*from   w  w w .  ja va  2 s.com*/
 */
public static void main(String[] args) {
    // create the command line parser
    CommandLineParser parser = new PosixParser();

    // create the Options
    Options optionsArg = new Options();
    Option helpOpt = new Option("?", "help", false, "print this message");
    Option inputFileOpt = new Option("f", "file", true, "the name of the xml file to show");
    inputFileOpt.setRequired(true);

    optionsArg.addOption(helpOpt);
    optionsArg.addOption(inputFileOpt);

    CommandLine line = null;
    try {
        // parse the command line arguments
        line = parser.parse(optionsArg, args);

        if (line.hasOption(helpOpt.getOpt())) {
            // automatically generate the help statement
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("vizgui", optionsArg);
            return;
        }

    } catch (ParseException exp) {
        System.err.println("Unexpected exception:" + exp.getMessage());
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("vizgui", optionsArg);
        return;
    }

    String inputFile = null;
    if (line.hasOption(inputFileOpt.getOpt())) {
        inputFile = line.getOptionValue(inputFileOpt.getOpt());
        if (inputFile == null) {
            System.err.println("Invalid input file");
        }
    }

    new edu.mit.csail.sdg.alloy4viz.VizGUI(true, inputFile, null);

}