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

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

Introduction

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

Prototype

public void printStackTrace() 

Source Link

Document

Prints this throwable and its backtrace to the standard error stream.

Usage

From source file:com.bc.fiduceo.post.PostProcessingToolMain.java

public static void main(String[] args) throws ParseException {
    final CommandLineParser parser = new PosixParser();
    final CommandLine commandLine;
    try {/*from  ww  w  .  ja  v  a2  s.co m*/
        commandLine = parser.parse(PostProcessingTool.getOptions(), args);
    } catch (ParseException e) {
        System.err.println(e.getMessage());
        System.err.println();
        PostProcessingTool.printUsageTo(System.err);
        return;
    }
    if (commandLine.hasOption("h") || commandLine.hasOption("--help")) {
        PostProcessingTool.printUsageTo(System.out);
        return;
    }

    try {
        final PostProcessingContext context = PostProcessingTool.initializeContext(commandLine);
        final PostProcessingTool tool = new PostProcessingTool(context);
        tool.runPostProcessing();
    } catch (Throwable e) {
        FiduceoLogger.getLogger().severe(e.getMessage());
        e.printStackTrace();
        System.exit(-1);
    }
}

From source file:com.opengamma.util.db.tool.DbTool.java

/**
 * Runs the tool from the command line./*from w w w .  java  2s. c o m*/
 * 
 * @param args  the command line arguments, not null
 */
public static void main(String[] args) { // CSIGNORE
    Options options = new Options();
    options.addOption("jdbcUrl", "jdbcUrl", true,
            "DB server URL + database - for example, jdbc:postgresql://localhost:1234/OpenGammaTests. You can use"
                    + " either this option or specify server and database separately.");
    options.addOption("server", "server", true,
            "DB server URL (no database at the end) - for example, jdbc:postgresql://localhost:1234");
    options.addOption("database", "database", true,
            "Name of database on the DB server - for example, OpenGammaTests");
    options.addOption("user", "user", true, "User name to the DB");
    options.addOption("password", "password", true, "Password to the DB");
    options.addOption("schema", "schema", true,
            "Name of schema within database. Optional. If not specified, the default schema for the database is used.");
    options.addOption("create", "create", false,
            "Creates the given database/schema. The database will be empty.");
    options.addOption("drop", "drop", false, "Drops all tables and sequences within the given database/schema");
    options.addOption("clear", "clear", false, "Clears all tables within the given database/schema");
    options.addOption("createtestdb", "createtestdb", true,
            "Drops schema in database test_<user.name> and recreates it (including tables). "
                    + "{dbtype} should be one of derby, postgres, all. Connection parameters are read from test.properties so you do not need "
                    + "to specify server, user, or password.");
    options.addOption("createtables", "createtables", true, "Creates database tables for all masters.");
    options.addOption("targetversion", "targetversion", true,
            "Version number for the end result database. 0 means latest. 1 means last but one etc. Optional. If not specified, assumes latest version.");
    options.addOption("createversion", "createversion", true,
            "Version number to run the creation script from. 0 means latest. 1 means last but one etc. Optional. If not specified, defaults to {targetversion}.");
    options.addOption("testpropertiesdir", "testpropertiesdir", true,
            "Directory for reading test.properties. Only used with the --createstdb option. "
                    + "Optional. If not specified, the working directory is used.");

    CommandLineParser parser = new PosixParser();
    CommandLine line = null;
    try {
        line = parser.parse(options, args);
    } catch (ParseException e) {
        e.printStackTrace();
        usage(options);
        System.exit(-1);
    }

    DbTool tool = new DbTool();
    tool.setJdbcUrl(line.getOptionValue("jdbcUrl"));
    tool.setDbServerHost(line.getOptionValue("server"));
    tool.setUser(line.getOptionValue("user"));
    tool.setPassword(line.getOptionValue("password"));
    tool.setCatalog(line.getOptionValue("database"));
    tool.setSchema(line.getOptionValue("schema"));
    tool.setCreate(line.hasOption("create"));
    tool.setDrop(line.hasOption("drop"));
    tool.setClear(line.hasOption("clear"));
    tool.setCreateTestDb(line.getOptionValue("createtestdb"));
    tool.setCreateTables(line.getOptionValue("createtables"));
    tool.setTestPropertiesDir(line.getOptionValue("testpropertiesdir"));
    tool.setTargetVersion(line.getOptionValue("targetversion"));
    tool.setCreateVersion(line.getOptionValue("createversion"));

    try {
        tool.execute();
    } catch (RuntimeException ex) {
        s_logger.error(ex.getMessage());
        usage(options);
        System.exit(-1);
    }
}

From source file:com.genentech.application.property.SDFCalculate.java

public static void main(String args[]) {
    String usage = "java SDFCalculate [options] <list of space separated properties>\n";

    Options options = new Options();
    // add  options
    options.addOption("TPSA_P", false, "Count phosphorus atoms, default is false. (optional)");
    options.addOption("TPSA_S", false, "Count sulfur atoms, default is false. (optional)");
    options.addOption("cLogP", true, "SDtag where cLogP is stored, default is cLogP (optional)");
    options.addOption("in", true, "inFile in OE formats: Ex: a.sdf or .sdf");
    options.addOption("out", true, "outputfile in OE formats. Ex: a.sdf or .sdf ");

    try {/*from ww  w.j  av  a 2s .co m*/
        boolean countS = false;
        boolean countP = false;

        // append list of valid properties and their descriptions to the usage statement
        Iterator<Entry<String, String>> i = propsMap.entrySet().iterator();
        while (i.hasNext()) {
            Map.Entry<String, String> me = i.next();
            usage = usage + me.getKey() + ":\t" + me.getValue() + "\n";
        }

        CommandLineParser parser = new PosixParser();
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("TPSA_P"))
            countP = true;
        if (cmd.hasOption("TPSA_S"))
            countS = true;

        // get list of properties
        Vector<String> propsList = new Vector<String>(Arrays.asList(cmd.getArgs()));
        if (propsList.isEmpty()) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(usage, options);
            System.exit(1);
        }
        //make sure list of requested pros are valid props
        for (String p : propsList) {
            if (!propsMap.containsKey(p)) {
                System.err.println(p + " is not a valid property.");
                HelpFormatter formatter = new HelpFormatter();
                formatter.printHelp(usage, options);
                System.exit(1);
            }
        }

        // get cLogP SD label tag option value
        String cLogPTag = "cLogP";

        if (cmd.hasOption("cLogP")) {
            cLogPTag = cmd.getOptionValue("cLogP");
        }

        String inFile = cmd.getOptionValue("in");
        if (inFile == null) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(usage, options);
            System.exit(1);
        }

        String outFile = cmd.getOptionValue("out");
        if (outFile == null) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(usage, options);
            System.exit(1);
        }

        String filename = "smarts.xml";
        URL url = SDFCalculate.class.getResource(filename);
        Element root = XMLUtil.getRootElement(url, false);

        SDFCalculate test = new SDFCalculate(outFile, cLogPTag, countP, countS, root);
        test.calcProperties(inFile, propsList);

    } catch (ParseException e) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(usage, options);
        System.exit(1);
    } catch (Exception e) {
        e.printStackTrace();
    }
}

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;//from  www  . ja va2  s.  co m

    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:edu.wustl.mir.erl.ihe.xdsi.util.StoreSCU.java

@SuppressWarnings("unchecked")
public static void main(String[] args) {
    long t1, t2;/*from   w w  w  .j a va 2s.c  o m*/
    try {
        CommandLine cl = parseComandLine(args);
        Device device = new Device("storescu");
        Connection conn = new Connection();
        device.addConnection(conn);
        ApplicationEntity ae = new ApplicationEntity("STORESCU");
        device.addApplicationEntity(ae);
        ae.addConnection(conn);
        StoreSCU main = new StoreSCU(ae);
        configureTmpFile(main, cl);
        CLIUtils.configureConnect(main.remote, main.rq, cl);
        CLIUtils.configureBind(conn, ae, cl);
        CLIUtils.configure(conn, cl);
        main.remote.setTlsProtocols(conn.getTlsProtocols());
        main.remote.setTlsCipherSuites(conn.getTlsCipherSuites());
        configureRelatedSOPClass(main, cl);
        main.setAttributes(new Attributes());
        CLIUtils.addAttributes(main.attrs, cl.getOptionValues("s"));
        main.setUIDSuffix(cl.getOptionValue("uid-suffix"));
        main.setPriority(CLIUtils.priorityOf(cl));
        List<String> argList = cl.getArgList();
        boolean echo = argList.isEmpty();
        if (!echo) {
            System.out.println(rb.getString("scanning"));
            t1 = System.currentTimeMillis();
            main.scanFiles(argList);
            t2 = System.currentTimeMillis();
            int n = main.filesScanned;
            System.out.println();
            if (n == 0)
                return;
            System.out.println(
                    MessageFormat.format(rb.getString("scanned"), n, (t2 - t1) / 1000F, (t2 - t1) / n));
        }
        ExecutorService executorService = Executors.newSingleThreadExecutor();
        ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
        device.setExecutor(executorService);
        device.setScheduledExecutor(scheduledExecutorService);
        try {
            t1 = System.currentTimeMillis();
            main.open();
            t2 = System.currentTimeMillis();
            System.out
                    .println(MessageFormat.format(rb.getString("connected"), main.as.getRemoteAET(), t2 - t1));
            if (echo)
                main.echo();
            else {
                t1 = System.currentTimeMillis();
                main.sendFiles();
                t2 = System.currentTimeMillis();
            }
        } finally {
            main.close();
            executorService.shutdown();
            scheduledExecutorService.shutdown();
        }
        if (main.filesScanned > 0) {
            float s = (t2 - t1) / 1000F;
            float mb = main.totalSize / 1048576F;
            System.out.println(MessageFormat.format(rb.getString("sent"), main.filesSent, mb, s, mb / s));
        }
    } catch (ParseException e) {
        System.err.println("storescu: " + e.getMessage());
        System.err.println(rb.getString("try"));
        System.exit(2);
    } catch (Exception e) {
        System.err.println("storescu: " + e.getMessage());
        e.printStackTrace();
        System.exit(2);
    }
}

From source file:edu.umass.cs.contextservice.installer.CSInstaller.java

/**
 * The main routine./*www  . j  av  a2  s .c o m*/
 * sample usage 
 * @param args
 * @throws IOException 
 * @throws UnknownHostException 
 * @throws NumberFormatException
 * java -cp ./release/context-nodoc-GNS.jar edu.umass.cs.contextservice.installer.CSInstaller -update singleNodeConf 
 */
public static void main(String[] args) throws NumberFormatException, UnknownHostException, IOException {
    try {
        CommandLine parser = initializeOptions(args);
        if (parser.hasOption("help") || args.length == 0) {
            printUsage();
            System.exit(1);
        }

        String runsetUpdate = parser.getOptionValue("update");
        String runsetRestart = parser.getOptionValue("restart");
        String runsetStop = parser.getOptionValue("stop");
        //boolean removeLogs = parser.hasOption("removeLogs");
        boolean deleteDatabase = parser.hasOption("deleteDatabase");
        String scriptFile = parser.getOptionValue("scriptFile");
        boolean withGNS = parser.hasOption("withGNS");
        //boolean noopTest = parser.hasOption("noopTest");

        /*if (dataStoreName != null) {
          try {
            dataStoreType = DataStoreType.valueOf(dataStoreName);
          } catch (IllegalArgumentException e) {
            System.out.println("Unknown data store type " + dataStoreName + "; exiting.");
            System.exit(1);
          }
        }*/

        String configName = runsetUpdate != null ? runsetUpdate
                : runsetRestart != null ? runsetRestart : runsetStop != null ? runsetStop : null;

        System.out.println("Config name: " + configName);
        System.out.println("Current directory: " + System.getProperty("user.dir"));

        determineJarAndMasterPaths();
        if (!checkAndSetConfFilePaths(configName)) {
            System.exit(1);
        }

        loadConfig(configName);

        if (getKeyFile() == null) {
            System.out.println("Can't find keyfile: " + keyFile + "; exiting.");
            System.exit(1);
        }

        loadCSConfFiles(configName);

        SSHClient.setVerbose(true);
        RSync.setVerbose(true);

        if (runsetUpdate != null) {
            updateRunSet(runsetUpdate, InstallerAction.UPDATE, deleteDatabase, scriptFile, withGNS);
        } else if (runsetRestart != null) {
            updateRunSet(runsetRestart, InstallerAction.RESTART, deleteDatabase, scriptFile, withGNS);
        } else if (runsetStop != null) {
            updateRunSet(runsetStop, InstallerAction.STOP, deleteDatabase, null, withGNS);
        } else {
            printUsage();
            System.exit(1);
        }
    } catch (ParseException e1) {
        e1.printStackTrace();
        printUsage();
        System.exit(1);
    }
    System.exit(0);
}

From source file:com.opengamma.util.test.DbTool.java

public static void main(String[] args) { // CSIGNORE
    Options options = new Options();
    options.addOption("jdbcUrl", "jdbcUrl", true,
            "DB server URL + database - for example, jdbc:postgresql://localhost:1234/OpenGammaTests. You can use"
                    + " either this option or specify server and database separately.");
    options.addOption("server", "server", true,
            "DB server URL (no database at the end) - for example, jdbc:postgresql://localhost:1234");
    options.addOption("database", "database", true,
            "Name of database on the DB server - for example, OpenGammaTests");
    options.addOption("user", "user", true, "User name to the DB");
    options.addOption("password", "password", true, "Password to the DB");
    options.addOption("schema", "schema", true,
            "Name of schema within database. Optional. If not specified, the default schema for the database is used.");
    options.addOption("create", "create", false,
            "Creates the given database/schema. The database will be empty.");
    options.addOption("drop", "drop", false, "Drops all tables and sequences within the given database/schema");
    options.addOption("clear", "clear", false, "Clears all tables within the given database/schema");
    options.addOption("createtestdb", "createtestdb", true,
            "Drops schema in database test_<user.name> and recreates it (including tables). "
                    + "{dbtype} should be one of derby, postgres, all. Connection parameters are read from test.properties so you do not need "
                    + "to specify server, user, or password.");
    options.addOption("createtables", "createtables", true,
            "Runs {dbscriptbasedir}/db/create/{dbtype}/<for-all-masters>/<latest version>__create-<master>.sql.");
    options.addOption("dbscriptbasedir", "dbscriptbasedir", true, "Directory for reading db create scripts. "
            + "Optional. If not specified, the working directory is used.");
    options.addOption("targetversion", "targetversion", true,
            "Version number for the end result database. 0 means latest. 1 means last but one etc. Optional. If not specified, assumes latest version.");
    options.addOption("createversion", "createversion", true,
            "Version number to run the creation script from. 0 means latest. 1 means last but one etc. Optional. If not specified, defaults to {targetversion}.");
    options.addOption("testpropertiesdir", "testpropertiesdir", true,
            "Directory for reading test.properties. Only used with the --createstdb option. "
                    + "Optional. If not specified, the working directory is used.");

    CommandLineParser parser = new PosixParser();
    CommandLine line = null;//from   ww  w  .  j  a va2s  .  c o  m
    try {
        line = parser.parse(options, args);
    } catch (ParseException e) {
        e.printStackTrace();
        usage(options);
        System.exit(-1);
    }

    DbTool tool = new DbTool();
    tool.setJdbcUrl(line.getOptionValue("jdbcUrl"));
    tool.setDbServerHost(line.getOptionValue("server"));
    tool.setUser(line.getOptionValue("user"));
    tool.setPassword(line.getOptionValue("password"));
    tool.setCatalog(line.getOptionValue("database"));
    tool.setSchema(line.getOptionValue("schema"));
    tool.setCreate(line.hasOption("create"));
    tool.setDrop(line.hasOption("drop"));
    tool.setClear(line.hasOption("clear"));
    tool.setCreateTestDb(line.getOptionValue("createtestdb"));
    tool.setCreateTables(line.getOptionValue("createtables"));
    tool.setTestPropertiesDir(line.getOptionValue("testpropertiesdir"));
    tool.addDbScriptDirectory(line.getOptionValue("dbscriptbasedir"));
    tool.setTargetVersion(line.getOptionValue("targetversion"));
    tool.setCreateVersion(line.getOptionValue("createversion"));

    try {
        tool.execute();
    } catch (BuildException e) {
        s_logger.error(e.getMessage());
        usage(options);
        System.exit(-1);
    }
}

From source file:edu.umass.cs.gnsserver.installer.GNSInstaller.java

/**
 * The main routine./*from w  w  w .  java  2 s. co m*/
 *
 * @param args
 */
public static void main(String[] args) {
    try {
        CommandLine parser = initializeOptions(args);
        if (parser.hasOption("help") || args.length == 0) {
            printUsage();
            System.exit(1);
        }
        String runsetUpdate = parser.getOptionValue("update");
        String runsetRestart = parser.getOptionValue("restart");
        String runsetScript = parser.getOptionValue("runscript");
        String runsetStop = parser.getOptionValue("stop");
        String dataStoreName = parser.getOptionValue("datastore");
        boolean removeLogs = parser.hasOption("removeLogs");
        boolean deleteDatabase = parser.hasOption("deleteDatabase");
        String scriptFile = parser.getOptionValue("scriptFile");
        boolean runAsRoot = parser.hasOption("root");
        boolean noopTest = parser.hasOption("noopTest");

        if (dataStoreName != null) {
            try {
                dataStoreType = DataStoreType.valueOf(dataStoreName);
            } catch (IllegalArgumentException e) {
                System.out.println("Unknown data store type " + dataStoreName + "; exiting.");
                System.exit(1);
            }
        }

        String configName = runsetUpdate != null ? runsetUpdate
                : runsetRestart != null ? runsetRestart : runsetStop != null ? runsetStop : null;
        if (configName == null && runsetScript != null) {
            configName = runsetScript;
        }

        System.out.println("Config name: " + configName);
        System.out.println("Current directory: " + System.getProperty("user.dir"));

        determineJarAndMasterPaths();
        if (!checkAndSetConfFilePaths(configName)) {
            System.exit(1);
        }

        if (getKeyFile() == null) {
            System.out.println("Can't find keyfile: " + keyFile + "; exiting.");
            System.exit(1);
        }

        loadConfig(configName);
        loadHostsFiles(configName);

        String lnsHostFile = fileSomewhere(configName + FILESEPARATOR + LNS_HOSTS_FILENAME, confFolderPath)
                .toString();
        String nsHostFile = fileSomewhere(configName + FILESEPARATOR + NS_HOSTS_FILENAME, confFolderPath)
                .toString();

        SSHClient.setVerbose(true);
        RSync.setVerbose(true);

        if (runsetScript != null) {
            updateRunSet(runsetUpdate, InstallerAction.SCRIPT_ONLY, removeLogs, deleteDatabase, lnsHostFile,
                    nsHostFile, scriptFile, runAsRoot, noopTest);
        } else if (runsetUpdate != null) {
            updateRunSet(runsetUpdate, InstallerAction.UPDATE, removeLogs, deleteDatabase, lnsHostFile,
                    nsHostFile, scriptFile, runAsRoot, noopTest);
        } else if (runsetRestart != null) {
            updateRunSet(runsetRestart, InstallerAction.RESTART, removeLogs, deleteDatabase, lnsHostFile,
                    nsHostFile, scriptFile, runAsRoot, noopTest);
        } else if (runsetStop != null) {
            updateRunSet(runsetStop, InstallerAction.STOP, removeLogs, deleteDatabase, null, null, null,
                    runAsRoot, noopTest);
        } else {
            printUsage();
            System.exit(1);
        }

    } catch (ParseException e1) {
        e1.printStackTrace();
        printUsage();
        System.exit(1);
    }
    System.exit(0);
}

From source file:com.genentech.application.calcProps.SDFCalcProps.java

public static void main(String args[]) {
    String usage = "sdfCalcProps [options] <list of space separated properties>\n";

    // create Options object
    Options options = new Options();
    // add  options
    options.addOption("h", false, "print help message.");
    options.addOption("help", false, "print help message.");
    options.addOption("in", true, "inFile in OE formats: Ex: a.sdf or .sdf");
    options.addOption("out", true, "outputfile in OE formats. Ex: a.sdf or .sdf ");
    options.addOption("useExp", false,
            "Use experimental values, if available, in property calculations. False by default.");
    options.addOption("addMolIndex", false,
            "Creates a sd Tag called Mol_Index for each molecule where the values are 1 .. N");
    options.addOption("predictTautomer", false,
            "Run tauthor to predict the most likely tautomer and neutralize it. False by default.");
    options.addOption("print", false,
            "Do not run calculation, just print out the list of SD tags that will be produced. False by default");
    options.addOption("dontFilter", false, "Do not run filter to remove \"bad\" molecules. False by default.");
    options.addOption("verbose", false, "Output verbose SD tags for each property. False by default.");
    options.addOption("debug", false,
            "Create a debug output SD file, not fully implemented. False by default.");
    options.addOption("showAll", false, "Print help for all properties, including non-public ones.");
    CommandLineParser parser = new PosixParser();

    try {/* w w w .  jav  a 2 s . c o  m*/
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("h") || cmd.hasOption("help")) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp(usage, options);
        }

        boolean useExp = false;
        if (cmd.hasOption("useExp")) {
            useExp = true;
        }

        boolean showAll = false;
        if (cmd.hasOption("showAll")) {
            showAll = true;
        }

        boolean predictTautomer = false;
        if (cmd.hasOption("predictTautomer")) {
            predictTautomer = true;
        }

        boolean dontFilter = false;
        if (cmd.hasOption("dontFilter")) {
            dontFilter = true;
        }

        boolean print = false;
        if (cmd.hasOption("print")) {
            print = true;
        }
        boolean verbose = false;
        if (cmd.hasOption("verbose")) {
            verbose = true;
        }

        boolean debug = false;
        if (cmd.hasOption("debug")) {
            debug = true;
        }

        boolean addMolIndex = false;
        if (cmd.hasOption("addMolIndex")) {
            addMolIndex = true;
        }

        String filename = "properties.xml";
        URL url = IOUtil.getConfigUrl(filename, Settings.AESTEL_INSTALL_PATH + "/config/properties",
                "/com/genentech/application/calcProps", false);
        Element root = XMLUtil.getRootElement(url, true);

        //get set of available calculators as defined in properties.xml
        Set<Calculator> availCALCS = readXML(root, useExp);

        if (cmd.getArgList().isEmpty()) {
            System.err.println("Enter at least one property");
            printProperties(availCALCS, showAll);
            exitWithHelp(usage, options);
        }

        if (showAll) {
            printProperties(availCALCS, showAll);
            exitWithHelp(usage, options);
        }

        String inFile = cmd.getOptionValue("in");
        if (inFile == null) {
            exitWithHelp(usage, options);
        }

        String outFile = cmd.getOptionValue("out");
        if (outFile == null) {
            exitWithHelp(usage, options);
        }

        //make sure requested args are valid
        if (containInvalidProps(cmd.getArgs(), availCALCS)) {
            printProperties(availCALCS, showAll);
            exitWithHelp(usage, options);
        }

        if (debug) {
            System.err.println("The following properties were requested:");
            for (String p : cmd.getArgs()) {
                System.err.print(p + " ");
            }
            System.err.println();
        }

        String[] props = cmd.getArgs();
        String command = calculate(props, predictTautomer, dontFilter, verbose, debug, print, addMolIndex,
                availCALCS, inFile, outFile);
        System.out.println(command);

    } catch (ParseException e) { // TODO print explanation
        throw new Error(e);
    } catch (IncorrectInputException e) {
        e.printStackTrace();
    } catch (IOException e) {
        throw new Error(e);
    } catch (InterruptedException e) {
        throw new Error(e);
    }
}

From source file:edu.ucsb.cs.eager.sa.cerebro.ProfessorX.java

public static void main(String[] args) {
    Options options = new Options();
    options.addOption("i", "input-file", true, "Path to input xml file");
    options.addOption("r", "root-path", true, "Root path of all Git repositories");

    CommandLine cmd;/*from   www. j av a2  s. c  o m*/
    try {
        CommandLineParser parser = new BasicParser();
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.err.println("Error: " + e.getMessage() + "\n");
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("Cerebro", options);
        return;
    }

    String inputFileName = cmd.getOptionValue("i");
    if (inputFileName == null) {
        System.err.println("input file path is required");
        return;
    }

    String rootPath = cmd.getOptionValue("r");
    if (rootPath == null) {
        System.err.println("root path is required");
        return;
    }

    File inputFile = new File(inputFileName);
    DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
    Document doc;
    try {
        DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
        doc = dBuilder.parse(inputFile);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        e.printStackTrace();
        return;
    }

    NodeList repoList = doc.getElementsByTagName("repo");
    for (int i = 0; i < repoList.getLength(); i++) {
        Element repo = (Element) repoList.item(i);
        String name = repo.getElementsByTagName("name").item(0).getTextContent();
        String classPath = repo.getElementsByTagName("classpath").item(0).getTextContent();
        Set<String> classes = new LinkedHashSet<String>();
        NodeList classesList = repo.getElementsByTagName("classes").item(0).getChildNodes();
        for (int j = 0; j < classesList.getLength(); j++) {
            if (!(classesList.item(j) instanceof Element)) {
                continue;
            }
            classes.add(classesList.item(j).getTextContent());
        }
        analyzeRepo(rootPath, name, classPath, classes);
    }
}