Example usage for org.apache.commons.cli CommandLine getArgs

List of usage examples for org.apache.commons.cli CommandLine getArgs

Introduction

In this page you can find the example usage for org.apache.commons.cli CommandLine getArgs.

Prototype

public String[] getArgs() 

Source Link

Document

Retrieve any left-over non-recognized options and arguments

Usage

From source file:bboss.org.artofsolving.jodconverter.cli.Convert.java

public static void main(String[] arguments) throws ParseException, JSONException, IOException {
    CommandLineParser commandLineParser = new PosixParser();
    CommandLine commandLine = commandLineParser.parse(OPTIONS, arguments);

    String outputFormat = null;/*from   w w  w  .j av  a2s  .c o m*/
    if (commandLine.hasOption(OPTION_OUTPUT_FORMAT.getOpt())) {
        outputFormat = commandLine.getOptionValue(OPTION_OUTPUT_FORMAT.getOpt());
    }

    int port = DEFAULT_OFFICE_PORT;
    if (commandLine.hasOption(OPTION_PORT.getOpt())) {
        port = Integer.parseInt(commandLine.getOptionValue(OPTION_PORT.getOpt()));
    }

    String[] fileNames = commandLine.getArgs();
    if ((outputFormat == null && fileNames.length != 2) || fileNames.length < 1) {
        String syntax = "java -jar jodconverter-core.jar [options] input-file output-file\n"
                + "or [options] -o output-format input-file [input-file...]";
        HelpFormatter helpFormatter = new HelpFormatter();
        helpFormatter.printHelp(syntax, OPTIONS);
        System.exit(STATUS_INVALID_ARGUMENTS);
    }

    DocumentFormatRegistry registry;
    if (commandLine.hasOption(OPTION_REGISTRY.getOpt())) {
        File registryFile = new File(commandLine.getOptionValue(OPTION_REGISTRY.getOpt()));
        registry = new JsonDocumentFormatRegistry(FileUtils.readFileToString(registryFile));
    } else {
        registry = new DefaultDocumentFormatRegistry();
    }

    DefaultOfficeManagerConfiguration configuration = new DefaultOfficeManagerConfiguration();
    configuration.setPortNumber(port);
    if (commandLine.hasOption(OPTION_TIMEOUT.getOpt())) {
        int timeout = Integer.parseInt(commandLine.getOptionValue(OPTION_TIMEOUT.getOpt()));
        configuration.setTaskExecutionTimeout(timeout * 1000);
    }
    if (commandLine.hasOption(OPTION_USER_PROFILE.getOpt())) {
        String templateProfileDir = commandLine.getOptionValue(OPTION_USER_PROFILE.getOpt());
        configuration.setTemplateProfileDir(new File(templateProfileDir));
    }

    OfficeManager officeManager = configuration.buildOfficeManager();
    officeManager.start();
    OfficeDocumentConverter converter = new OfficeDocumentConverter(officeManager, registry);
    try {
        if (outputFormat == null) {
            File inputFile = new File(fileNames[0]);
            File outputFile = new File(fileNames[1]);
            converter.convert(inputFile, outputFile);
        } else {
            for (int i = 0; i < fileNames.length; i++) {
                File inputFile = new File(fileNames[i]);
                String outputName = FilenameUtils.getBaseName(fileNames[i]) + "." + outputFormat;
                File outputFile = new File(FilenameUtils.getFullPath(fileNames[i]) + outputName);
                converter.convert(inputFile, outputFile);
            }
        }
    } finally {
        officeManager.stop();
    }
}

From source file:com.aestel.chemistry.openEye.fp.Fingerprinter.java

public static void main(String... args) throws IOException {
    long start = System.currentTimeMillis();
    long iCounter = 0;

    // create command line Options object
    Options options = new Options();
    Option opt = new Option("in", true, "input file [.ism,.sdf,...]");
    opt.setRequired(true);/* ww  w  .j  a v  a  2  s .c  o  m*/
    options.addOption(opt);

    opt = new Option("out", true, "output file .tsv or oe-supported");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("idTag", true, "field with ID (default title)");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("fpType", true, "fingerPrintType: maccs|linear7|linear7*4|HashLinear7*4\n"
            + "   maccs: generate maccs keys\n"
            + "   linear7 generate 7 bonds long linear fingerprints (210k known rest hashed)\n"
            + "   linear7*4 linear 7 bonds if more than 4 atoms code atoms as * (5.1k known rest hashed)\n"
            + "   HashLinear7*4: as linear7*4 but hashed to 16k");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("format", true,
            "folded512|folded2048|bitList|fragList|none\n" + "   folded512/2048: hex encoded 512/2048 bits\n"
                    + "   bitList: list of bitpositions\n" + "   none: no fp output for use with writeCodeMap");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("writeCodeMap", false, "Overwrite the codeMap file at the end of processing");
    opt.setRequired(false);
    options.addOption(opt);

    CommandLineParser parser = new PosixParser();
    CommandLine cmd = null;
    try {
        cmd = parser.parse(options, args);
    } catch (Exception e) {
        System.err.println(e.getMessage());
        exitWithHelp(options);
    }
    args = cmd.getArgs();

    if (cmd.hasOption("d")) {
        System.err.println("Start debugger and press return:");
        new BufferedReader(new InputStreamReader(System.in)).readLine();
    }

    String idTag = null;
    if (cmd.hasOption("idTag"))
        idTag = cmd.getOptionValue("idTag");

    String outformat = cmd.getOptionValue("format").toLowerCase().intern();
    if (args.length != 0) {
        exitWithHelp(options);
    }

    String type = cmd.getOptionValue("fpType");
    boolean updateDictionaryFile = cmd.hasOption("writeCodeMap");
    boolean hashUnknownFrag = true;
    if (type.equals("HashLinear7*4"))
        hashUnknownFrag = false;
    if (type.equals("maccs"))
        hashUnknownFrag = false;
    if (updateDictionaryFile)
        hashUnknownFrag = false;
    Fingerprinter fprinter = createFingerprinter(type, updateDictionaryFile, hashUnknownFrag);
    OEMolBase mol = new OEGraphMol();

    String inFile = cmd.getOptionValue("in");
    String outFile = cmd.getOptionValue("out");
    oemolistream ifs = new oemolistream(inFile);

    Runtime rt = Runtime.getRuntime();
    Outputter out;
    if (outFile.endsWith(".txt") || outFile.endsWith(".tab"))
        out = new TabOutputter(fprinter.getMapper(), outFile, outformat);
    else
        out = new OEOutputter(fprinter.getMapper(), outFile, type, outformat);

    while (oechem.OEReadMolecule(ifs, mol)) {
        iCounter++;
        Fingerprint fp = fprinter.getFingerprint(mol);

        String id;
        if (idTag == null)
            id = mol.GetTitle();
        else
            id = oechem.OEGetSDData(mol, idTag);

        if (iCounter % 100 == 0)
            System.err.print(".");
        if (iCounter % 4000 == 0) {
            System.err.printf(" %d %dsec\tt=%d f=%d u=%d m=%d tf=%d\n", iCounter,
                    (System.currentTimeMillis() - start) / 1000, rt.totalMemory() / 1024,
                    rt.freeMemory() / 1024, (rt.totalMemory() - rt.freeMemory()) / 1024, rt.maxMemory() / 1024,
                    (rt.freeMemory() + (rt.maxMemory() - rt.totalMemory())) / 1024);
        }

        out.output(id, mol, fp);
    }

    System.err.printf("Fingerprinter: Read %d structures in %d sec\n", iCounter,
            (System.currentTimeMillis() - start) / 1000);

    if (updateDictionaryFile)
        fprinter.writeDictionary();
    out.close();
    fprinter.close();
}

From source file:com.chip8java.emulator.Runner.java

/**
 * Runs the emulator with the specified command line options.
 * //from   ww  w.jav  a  2  s .  c  om
 * @param argv
 *            The set of options passed to the emulator
 */
public static void main(String[] argv) {
    CommandLine commandLine = parseCommandLineOptions(argv);
    Emulator.Builder emulatorBuilder = new Emulator.Builder();

    if (commandLine.hasOption(HELP_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("emulator", generateOptions());
        System.exit(0);
    }

    if (commandLine.hasOption(SCALE_OPTION)) {
        int scale = Integer.parseInt(commandLine.getOptionValue(SCALE_OPTION));
        emulatorBuilder.setScale(scale);
    }

    String[] args = commandLine.getArgs();
    if (args.length != 0) {
        emulatorBuilder.setRom(args[0]);
    }

    if (commandLine.hasOption(TRACE_OPTION)) {
        emulatorBuilder.setTrace();
    }

    if (commandLine.hasOption(DELAY_OPTION)) {
        int delay = Integer.parseInt(commandLine.getOptionValue(DELAY_OPTION));
        emulatorBuilder.setCycleTime((long) delay);
    }

    Emulator emulator = emulatorBuilder.build();
    emulator.start();
}

From source file:net.sf.jsignpdf.verify.SignatureCounter.java

/**
 * Main program.//w w  w . ja  va 2  s. c o m
 * 
 * @param args
 */
public static void main(String[] args) {

    // create the Options
    final Option optHelp = new Option("h", "help", false, "print this message");
    final Option optDebug = new Option("d", "debug", false, "enables debug output");
    final Option optNames = new Option("n", "names", false,
            "print comma separated signature names instead of the count");
    final Option optPasswd = new Option("p", "password", true, "set password for opening PDF");
    optPasswd.setArgName("password");

    final Options options = new Options();
    options.addOption(optHelp);
    options.addOption(optDebug);
    options.addOption(optNames);
    options.addOption(optPasswd);

    CommandLine line = null;
    try {
        // create the command line parser
        CommandLineParser parser = new PosixParser();
        // parse the command line arguments
        line = parser.parse(options, args);
    } catch (ParseException exp) {
        System.err.println("Unable to parse command line (Use -h for the help)\n" + exp.getMessage());
        System.exit(Constants.EXIT_CODE_PARSE_ERR);
    }

    final String[] tmpArgs = line.getArgs();
    if (line.hasOption("h") || args == null || args.length == 0) {
        // automatically generate the help statement
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(70, "java -jar SignatureCounter.jar [file1.pdf [file2.pdf ...]]",
                "JSignPdf SignatureCounter is a command line tool which prints count of signatures in given PDF document.",
                options, null, true);
    } else {
        byte[] tmpPasswd = null;
        if (line.hasOption("p")) {
            tmpPasswd = line.getOptionValue("p").getBytes();
        }
        final boolean debug = line.hasOption("d");
        final boolean names = line.hasOption("n");

        for (String tmpFilePath : tmpArgs) {
            if (debug) {
                System.out.print("Counting signatures in " + tmpFilePath + ": ");
            }
            final File tmpFile = new File(tmpFilePath);
            if (!tmpFile.canRead()) {
                System.err.println("Couldn't read the file. Check the path and permissions: " + tmpFilePath);
                System.exit(Constants.EXIT_CODE_CANT_READ_FILE);
            }
            try {
                final PdfReader pdfReader = PdfUtils.getPdfReader(tmpFilePath, tmpPasswd);
                @SuppressWarnings("unchecked")
                final List<String> sigNames = pdfReader.getAcroFields().getSignatureNames();
                if (names) {
                    //print comma-separated names
                    boolean isNotFirst = false;
                    for (String sig : sigNames) {
                        if (isNotFirst) {
                            System.out.println(",");
                        } else {
                            isNotFirst = true;
                        }
                        System.out.println(sig);
                    }
                } else {
                    //normal processing print only count of signatures
                    System.out.println(sigNames.size());
                    if (debug) {
                        System.out.println("Signature names: " + sigNames);
                    }
                }
            } catch (IOException e) {
                e.printStackTrace();
                System.exit(Constants.EXIT_CODE_COMMON_ERROR);
            }
        }
    }
}

From source file:io.github.azige.whitespace.Cli.java

public static void main(String[] args) {
    Options options = new Options().addOption("h", "help", false, "??")
            .addOptionGroup(new OptionGroup()
                    .addOption(new Option("p",
                            "????????"))
                    .addOption(new Option("c", "?????")))
            .addOption(null, "szm", false,
                    "????")
            .addOption("e", "encoding", true, "??" + DEFAULT_ENCODING);

    try {//from  w  ww .j a v a  2  s. c om
        CommandLineParser parser = new BasicParser();
        CommandLine cl = parser.parse(options, args);

        if (cl.hasOption('h')) {
            printHelp(System.out, options);
            return;
        }

        if (cl.hasOption('e')) {
            encoding = Charset.forName(cl.getOptionValue('e'));
        } else {
            encoding = Charset.forName(DEFAULT_ENCODING);
        }

        if (cl.hasOption("szm")) {
            useSzm = true;
        }

        String[] fileArgs = cl.getArgs();
        if (fileArgs.length != 1) {
            printHelp(System.err, options);
            return;
        }

        try (InputStream input = Files.newInputStream(Paths.get(fileArgs[0]))) {
            if (cl.hasOption('p')) {
                printPseudoCode(input);
            } else if (cl.hasOption('c')) {
                compile(input, fileArgs[0]);
            } else {
                execute(input, fileArgs[0]);
            }
        }
    } catch (ParseException ex) {
        ex.printStackTrace();
        printHelp(System.err, options);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
}

From source file:com.anjlab.sat3.Program.java

public static void main(String[] args) throws Exception {
    System.out.println("Reference Implementation of Romanov's Polynomial Algorithm for 3-SAT Problem"
            + "\nCopyright (c) 2010 AnjLab" + "\nThis program comes with ABSOLUTELY NO WARRANTY."
            + "\nThis is free software, and you are welcome to redistribute it under certain conditions."
            + "\nSee LICENSE.txt file or visit <http://www.gnu.org/copyleft/lesser.html> for details.");

    LOGGER.debug("Reading version number from manifest");
    String implementationVersion = Helper.getImplementationVersionFromManifest("3-SAT Core RI");
    System.out.println("Version: " + implementationVersion + "\n");

    Options options = getCommandLineOptions();

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

    if (commandLine.getArgs().length != 1 || commandLine.hasOption(HELP_OPTION)) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp(Program.class.getName() + " [OPTIONS] <input-file-name>"
                + "\nWhere <input-file-name> is a path to file containing k-SAT formula instance in DIMACS CNF or Romanov SKT file format.",
                options);//from w w  w.jav a  2 s  .c  o m
        System.exit(0);
    }

    String formulaFile = commandLine.getArgs()[0];

    Helper.UsePrettyPrint = commandLine.hasOption(USE_PRETTY_PRINT_OPTION);
    Helper.EnableAssertions = !commandLine.hasOption(DISABLE_ASSERTIONS_OPTION);
    Helper.UseUniversalVarNames = !commandLine.hasOption(USE_ABC_VAR_NAMES_OPTION);

    Properties statistics = new Properties();
    StopWatch stopWatch = new StopWatch();

    try {
        statistics.put(Helper.IMPLEMENTATION_VERSION, implementationVersion);

        stopWatch.start("Load formula");
        ITabularFormula formula = Helper.loadFromFile(formulaFile);
        long timeElapsed = stopWatch.stop();

        statistics.put(Helper.INITIAL_FORMULA_LOAD_TIME, String.valueOf(timeElapsed));

        if (commandLine.hasOption(GENERATE_3SAT_OPTION)) {
            String generated3SatFilename = formulaFile + "-3sat.cnf";

            LOGGER.info("Saving 3-SAT formula to {}...", generated3SatFilename);
            Helper.saveToDIMACSFileFormat(formula, generated3SatFilename);
        }

        if (formula.getVarCount() > 26) {
            LOGGER.info("Variables count > 26 => force using universal names for variables.");
            Helper.UseUniversalVarNames = true;
        }

        statistics.put(Helper.INITIAL_FORMULA_VAR_COUNT, String.valueOf(formula.getVarCount()));
        statistics.put(Helper.INITIAL_FORMULA_CLAUSES_COUNT, String.valueOf(formula.getClausesCount()));

        Helper.prettyPrint(formula);
        stopWatch.printElapsed();

        if (commandLine.hasOption(FIND_HSS_ROUTE_OPTION)) {
            String hssPath = commandLine.getOptionValue(FIND_HSS_ROUTE_OPTION);

            stopWatch.start("Load HSS from " + hssPath);
            ObjectArrayList hss = Helper.loadHSS(hssPath);
            stopWatch.stop();
            stopWatch.printElapsed();

            findHSSRoute(commandLine, formulaFile, statistics, stopWatch, formula, null, null, hss, hssPath);

            return;
        }

        if (commandLine.hasOption(EVALUATE_OPTION)) {
            String resultsFilename = commandLine.getOptionValue(EVALUATE_OPTION);
            boolean satisfiable = evaluateFormula(stopWatch, formula, resultsFilename);
            if (satisfiable) {
                System.out.println("Formula evaluated as SAT");
            } else {
                System.out.println("Formula evaluated as UNSAT");
            }
            //  Only evaluate formula value
            return;
        }

        //  Find if formula is SAT

        //  Clone initial formula to verify formula satisfiability later
        ITabularFormula formulaClone = null;
        if (Helper.EnableAssertions) {
            stopWatch.start("Clone initial formula");
            formulaClone = formula.clone();
            stopWatch.stop();
            stopWatch.printElapsed();
        }

        stopWatch.start("Create CTF");
        ObjectArrayList ct = Helper.createCTF(formula);
        timeElapsed = stopWatch.stop();
        printFormulas(ct);
        stopWatch.printElapsed();

        statistics.put(Helper.CTF_CREATION_TIME, String.valueOf(timeElapsed));
        statistics.put(Helper.CTF_COUNT, String.valueOf(ct.size()));

        LOGGER.info("CTF count: {}", ct.size());

        if (Helper.EnableAssertions) {
            assertNoTripletsLost(formula, ct);
        }

        //  Clone CTF to verify formula satisfiability against it later
        ObjectArrayList ctfClone = null;

        if (Helper.EnableAssertions) {
            ctfClone = Helper.cloneStructures(ct);
        }

        stopWatch.start("Create CTS");
        Helper.completeToCTS(ct, formula.getPermutation());
        timeElapsed = stopWatch.stop();
        printFormulas(ct);
        stopWatch.printElapsed();

        statistics.put(Helper.CTS_CREATION_TIME, String.valueOf(timeElapsed));

        if (commandLine.hasOption(CREATE_SKT_OPTION)) {
            String sktFilename = formulaFile + ".skt";
            stopWatch.start("Convert CTS to " + sktFilename);
            Helper.convertCTStructuresToRomanovSKTFileFormat(ct, sktFilename);
            stopWatch.stop();
            stopWatch.printElapsed();

            return;
        }

        ObjectArrayList hss = unifyAndCreateHSS(statistics, stopWatch, ct);

        String hssPath = formulaFile + "-hss";
        stopWatch.start("Save HSS to " + hssPath + "...");
        Helper.saveHSS(hssPath, hss);
        stopWatch.stop();
        stopWatch.printElapsed();

        findHSSRoute(commandLine, formulaFile, statistics, stopWatch, formula, formulaClone, ctfClone, hss,
                hssPath);
    } catch (EmptyStructureException e) {
        stopWatch.stop();
        stopWatch.printElapsed();

        LOGGER.info("One of the structures was built empty", e);

        String resultsFilename = getResultsFilename(commandLine, formulaFile);
        stopWatch.start("Saving current statictics of calculations to " + resultsFilename);
        writeUnsatToFile(resultsFilename, statistics);
        stopWatch.stop();
        stopWatch.printElapsed();

        System.out.println("Formula not satisfiable");
    } finally {
        System.out.println("Program completed");
    }
}

From source file:jlite.cli.JobMatch.java

public static void main(String[] args) {
    System.out.println(); // extra line
    CommandLineParser parser = new GnuParser();
    Options options = setupOptions();/*from  w  w  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);
        } else {
            if (line.hasOption("xml")) {
                System.out.println("<output>");
            }
            String[] remArgs = line.getArgs();
            if (remArgs.length == 1) {
                run(remArgs[0], line);
            } else if (remArgs.length == 0) {
                throw new MissingArgumentException("Missing required argument: <jdl_file>");
            } else {
                throw new UnrecognizedOptionException("Unrecognized extra arguments");
            }
        }
    } 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 {
        if (line.hasOption("xml")) {
            System.out.println("</output>");
        }
    }
    System.out.println(); // extra line
}

From source file:com.zimbra.common.util.RandomPassword.java

public static void main(String args[]) {
    CommandLineParser parser = new GnuParser();
    Options options = new Options();
    options.addOption("l", "localpart", false, "generated string does not contain dot(.)");

    CommandLine cl = null;
    boolean err = false;

    try {/*from   w  w w.ja va 2s.c o m*/
        cl = parser.parse(options, args, true);
    } catch (ParseException pe) {
        System.err.println("error: " + pe.getMessage());
        err = true;
    }

    if (err || cl.hasOption('h')) {
        usage();
    }

    boolean localpart = false;
    int minLength = DEFAULT_MIN_LENGTH;
    int maxLength = DEFAULT_MAX_LENGTH;

    if (cl.hasOption('l'))
        localpart = true;

    args = cl.getArgs();

    if (args.length != 0) {
        if (args.length != 2) {
            usage();
        }
        try {
            minLength = Integer.valueOf(args[0]).intValue();
            maxLength = Integer.valueOf(args[1]).intValue();
        } catch (Exception e) {
            System.err.println(e);
            e.printStackTrace();
        }
    }

    System.out.println(generate(minLength, maxLength, localpart));
}

From source file:name.martingeisse.ecotools.simulator.ui.Main.java

/**
 * The main method./* w  w w  .j  av a 2s.co m*/
 * @param args command-line arguments
 * @throws Exception Any exceptions are passed to the environment.
 */
public static void main(String[] args) throws Exception {

    /** define command-line options **/
    Options options = new Options();
    options.addOption("i", false, "interactive mode (do not start simulation automatically)");
    options.addOption("l", true, "load program");
    options.addOption("r", true, "load ROM contents");
    options.addOption("d", true, "enable disk simulation with the specified disk image file");
    options.addOption("t", true, "enable terminal simulation with the specified number of terminals (0..2)");
    options.addOption("g", false, "enable graphics controller simulation");
    options.addOption("c", false, "enable console simulation");
    options.addOption("C", false, "enable block console simulation");
    options.addOption("o", true, "enable output device simulation and write output to the specified file");
    options.addOption("s", false, "enable null sound device");

    /** print help for the empty command line **/
    if (args.length == 0) {
        showUsgeAndExit(options);
    }

    /** parse the command line **/
    CommandLineParser commandLineParser = new PosixParser();
    CommandLine commandLine;
    try {
        commandLine = commandLineParser.parse(options, args);
    } catch (UnrecognizedOptionException e) {
        System.out.println("unrecognized option: " + e.getOption());
        showUsgeAndExit(options);
        return;
    }

    /** build the simulator configuration **/
    SimulatorConfiguration configuration = new SimulatorConfiguration();

    /** load configuration files **/
    for (String arg : commandLine.getArgs()) {
        configuration.loadConfigurationFile(arg);
    }

    /** interpret the options **/

    if (commandLine.hasOption("l")) {
        configuration.setProgramFilename(commandLine.getOptionValue("l"));
    }

    if (commandLine.hasOption("r")) {
        configuration.setRomFilename(commandLine.getOptionValue("r"));
    }

    if (commandLine.hasOption("d")) {
        configuration.setDiskFilename(commandLine.getOptionValue("d"));
    }

    if (commandLine.hasOption("t")) {
        String terminalCountSpecification = commandLine.getOptionValue("t");
        try {
            configuration.setTerminalCount(
                    (terminalCountSpecification == null) ? 0 : Integer.parseInt(terminalCountSpecification));
        } catch (NumberFormatException e) {
            System.out.println("number format error in number of terminals: " + terminalCountSpecification);
        }
    }

    if (commandLine.hasOption("i")) {
        configuration.setInteractive(true);
    }

    if (commandLine.hasOption("g")) {
        configuration.setGraphics(true);
    }

    if (commandLine.hasOption("c")) {
        configuration.setConsole(true);
    }

    if (commandLine.hasOption("C")) {
        configuration.setBlockConsole(true);
    }

    if (commandLine.hasOption("o")) {
        configuration.setOutputFilename(commandLine.getOptionValue("o"));
    }

    if (commandLine.hasOption("s")) {
        configuration.setSound(true);
    }

    configuration.checkConsistency();
    configuration.deriveSettings();

    /** setup simulation framework and run **/
    EcoSimulatorFramework framework = new EcoSimulatorFramework();
    configuration.applyPreCreate(framework);
    framework.create();
    configuration.applyPostCreate(framework);
    framework.open();
    framework.mainLoop();
    framework.dispose();
    framework.exit();

}

From source file:edu.msu.cme.rdp.classifier.train.validation.distance.PairwiseSeqDistance.java

/**
* This program does the pairwise alignment between each pair of sequences, 
* reports a summary of the average distances and the stdev at each rank.
* @param args//from   ww  w .j a  va2  s.co m
* @throws Exception 
*/
public static void main(String[] args) throws Exception {

    String trainseqFile = null;
    String taxFile = null;
    PrintStream outStream = null;
    AlignmentMode mode = AlignmentMode.overlap;
    boolean show_alignment = false;

    try {
        CommandLine line = new PosixParser().parse(options, args);

        if (line.hasOption("show_alignment")) {
            show_alignment = true;
        }
        if (line.hasOption("alignment-mode")) {
            String m = line.getOptionValue("alignment-mode").toLowerCase();
            mode = AlignmentMode.valueOf(m);

        }

        if (args.length != 3) {
            throw new Exception("wrong arguments");
        }
        args = line.getArgs();
        trainseqFile = args[0];
        taxFile = args[1];
        outStream = new PrintStream(new File(args[2]));
    } catch (Exception e) {
        System.err.println("Command Error: " + e.getMessage());
        new HelpFormatter().printHelp(80, " [options] trainseqFile taxonFile outFile", "", options, "");
        return;
    }

    PairwiseSeqDistance theObj = new PairwiseSeqDistance(trainseqFile, taxFile, mode, show_alignment);

    theObj.printSummary(outStream);
}