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

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

Introduction

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

Prototype

public String getOptionValue(char opt) 

Source Link

Document

Retrieve the argument, if any, of this option.

Usage

From source file:CountandraServer.java

public static void main(String args[]) {

    try {//from   w ww  .  j  ava 2s.co m
        System.out.println(args[0]);

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

        if (line.hasOption("cassandrahostip")) {
            CountandraUtils.setCassandraHostIp(line.getOptionValue("cassandrahostip"));
            if (line.hasOption("consistencylevel")) {
                if (line.hasOption("replicationfactor")) {

                    CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"),
                            line.getOptionValue("consistencylevel"));
                    CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"),
                            line.getOptionValue("replicationfactor"));

                } else {

                    CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"),
                            line.getOptionValue("consistencylevel"));
                    CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"));

                }
            }

            else { // no consistency level -- assumed to be ONE
                if (line.hasOption("replicationfactor")) {

                    CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"));
                    CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"),
                            line.getOptionValue("replicationfactor"));

                } else {

                    CassandraStorage.setGlobalParams(line.getOptionValue("cassandrahostip"));
                    CassandraDB.setGlobalParams(line.getOptionValue("cassandrahostip"));

                }
            }
        } else {
            CassandraStorage.setGlobalParams(cassandraServerForClient);
            CassandraDB.setGlobalParams(cassandraServerForClient);
        }

        if (line.hasOption("s")) {
            System.out.println("Starting Cassandra");
            // cassandra server
            CassandraUtils.startupCassandraServer();

        }
        if (line.hasOption("i")) {
            System.out.print("Checking if Cassandra is initialized");
            CassandraDB csdb = new CassandraDB();
            while (!csdb.isCassandraUp()) {
                System.out.print(".");
            }
            System.out.println(".");
            System.out.println("Initializing Basic structures");
            CountandraUtils.initBasicDataStructures();
            System.out.println("Initialized Basic structures");

        }

        if (line.hasOption("h")) {

            if (line.hasOption("httpserverport")) {
                httpPort = Integer.parseInt(line.getOptionValue("httpserverport"));
            }
            NettyUtils.startupNettyServer(httpPort);
            System.out.println("Started Http Server");
        }

        if (line.hasOption("k")) {

            KafkaUtils.startupKafkaConsumer();
            System.out.println("Started Kafka Consumer");
        }

        // Unit Tests
        if (line.hasOption("t")) {
            try {
                Thread.sleep(30000);
            } catch (InterruptedException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            org.junit.runner.JUnitCore.main(CountandraTestCases.class.getName());
        }

    } catch (IOException ioe) {
        System.out.println(ioe);
    } catch (Exception e) {
        System.out.println(e);
    }
}

From source file:com.opensearchserver.affinities.Main.java

public static void main(String[] args) throws IOException, ParseException {
    Logger.getLogger("").setLevel(Level.WARNING);
    Options options = new Options();
    options.addOption("h", "help", false, "print this message");
    options.addOption("d", "datadir", true, "Data directory");
    options.addOption("p", "port", true, "TCP port");
    CommandLineParser parser = new GnuParser();
    CommandLine cmd = parser.parse(options, args);
    if (cmd.hasOption("help")) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("java -jar target/oss-affinities.jar", options);
        return;//from  w ww.  j  a va 2  s. c om
    }
    int port = cmd.hasOption("p") ? Integer.parseInt(cmd.getOptionValue("p")) : 9092;

    File dataDir = new File(System.getProperty("user.home"), "opensearchserver_affinities");
    if (cmd.hasOption("d"))
        dataDir = new File(cmd.getOptionValue("d"));
    if (!dataDir.exists())
        throw new IOException("The data directory does not exists: " + dataDir);
    if (!dataDir.isDirectory())
        throw new IOException("The data directory path is not a directory: " + dataDir);
    AffinityList.load(dataDir);

    UndertowJaxrsServer server = new UndertowJaxrsServer()
            .start(Undertow.builder().addHttpListener(port, "0.0.0.0"));
    server.deploy(Main.class);
}

From source file:edu.toronto.cs.xcurator.cli.CLIRunner.java

public static void main(String[] args) {
    Options options = setupOptions();//from ww w .  ja v  a  2 s. co m
    CommandLineParser parser = new BasicParser();
    try {
        CommandLine line = parser.parse(options, args);
        if (line.hasOption('t')) {
            fileType = line.getOptionValue('t');
        } else {
            fileType = XML;
        }
        if (line.hasOption('o')) {
            tdbDirectory = line.getOptionValue('o');
            File d = new File(tdbDirectory);
            if (!d.exists() || !d.isDirectory()) {
                throw new Exception("TDB directory does not exist, please create.");
            }
        }
        if (line.hasOption('h')) {
            domain = line.getOptionValue('h');
            try {
                URL url = new URL(domain);
            } catch (MalformedURLException ex) {
                throw new Exception("The domain name is ill-formed");
            }
        } else {
            printHelpAndExit(options);
        }
        if (line.hasOption('m')) {
            serializeMapping = true;
            mappingFilename = line.getOptionValue('m');
        }
        if (line.hasOption('d')) {
            dirLocation = line.getOptionValue('d');
            inputStreams = new ArrayList<>();
            final List<String> files = Util.getFiles(dirLocation);
            for (String inputfile : files) {
                File f = new File(inputfile);
                if (f.isFile() && f.exists()) {
                    System.out.println("Adding document to mapping discoverer: " + inputfile);
                    inputStreams.add(new FileInputStream(f));
                } // If it is a URL download link for the document from SEC
                else if (inputfile.startsWith("http") && inputfile.contains("://")) {
                    // Download
                    System.out.println("Adding remote document to mapping discoverer: " + inputfile);
                    try {
                        URL url = new URL(inputfile);
                        InputStream remoteDocumentStream = url.openStream();
                        inputStreams.add(remoteDocumentStream);
                    } catch (MalformedURLException ex) {
                        throw new Exception("The document URL is ill-formed: " + inputfile);
                    } catch (IOException ex) {
                        throw new Exception("Error in downloading remote document: " + inputfile);
                    }
                } else {
                    throw new Exception("Cannot open XBRL document: " + f.getName());
                }
            }
        }

        if (line.hasOption('f')) {
            fileLocation = line.getOptionValue('f');
            inputStreams = new ArrayList<>();
            File f = new File(fileLocation);
            if (f.isFile() && f.exists()) {
                System.out.println("Adding document to mapping discoverer: " + fileLocation);
                inputStreams.add(new FileInputStream(f));
            } // If it is a URL download link for the document from SEC
            else if (fileLocation.startsWith("http") && fileLocation.contains("://")) {
                // Download
                System.out.println("Adding remote document to mapping discoverer: " + fileLocation);
                try {
                    URL url = new URL(fileLocation);
                    InputStream remoteDocumentStream = url.openStream();
                    inputStreams.add(remoteDocumentStream);
                } catch (MalformedURLException ex) {
                    throw new Exception("The document URL is ill-formed: " + fileLocation);
                } catch (IOException ex) {
                    throw new Exception("Error in downloading remote document: " + fileLocation);
                }
            } else {

                throw new Exception("Cannot open XBRL document: " + f.getName());
            }

        }

        setupDocumentBuilder();
        RdfFactory rdfFactory = new RdfFactory(new RunConfig(domain));
        List<Document> documents = new ArrayList<>();
        for (InputStream inputStream : inputStreams) {
            Document dataDocument = null;
            if (fileType.equals(JSON)) {
                String json = IOUtils.toString(inputStream);
                final String xml = Util.json2xml(json);
                final InputStream xmlInputStream = IOUtils.toInputStream(xml);
                dataDocument = createDocument(xmlInputStream);
            } else {
                dataDocument = createDocument(inputStream);
            }
            documents.add(dataDocument);
        }
        if (serializeMapping) {
            System.out.println("Mapping file will be saved to: " + new File(mappingFilename).getAbsolutePath());
            rdfFactory.createRdfs(documents, tdbDirectory, mappingFilename);
        } else {
            rdfFactory.createRdfs(documents, tdbDirectory);
        }
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println("Unexpected exception: " + ex.getMessage());
        System.exit(1);
    }
}

From source file:com.basingwerk.utilisation.Utilisation.java

public static void main(final String[] args) {
    String dataFile = null;// w w w .  ja v a  2s . co  m

    Options options = new Options();

    Option helpOption = new Option("h", "help", false, "print this help");
    Option serverURLOption = new Option("l", "logfile", true, "log file");

    options.addOption(helpOption);
    options.addOption(serverURLOption);

    CommandLineParser argsParser = new PosixParser();

    try {
        CommandLine commandLine = argsParser.parse(options, args);

        if (commandLine.hasOption(helpOption.getOpt())) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Usage grapher", options);
            System.exit(0);
        }

        dataFile = commandLine.getOptionValue(serverURLOption.getOpt());
        String[] otherArgs = commandLine.getArgs();

        if (dataFile == null || otherArgs.length > 1) {
            System.out.println("Please specify a logfile");
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("Usage grapher", options);
            System.exit(0);
        }

    } catch (ParseException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    } finally {
    }

    final UsagePlotter demo = new UsagePlotter("Usage", new File(dataFile));
    demo.pack();
    RefineryUtilities.centerFrameOnScreen(demo);
    demo.setVisible(true);
}

From source file:com.bialx.ebics.FDL.java

public static void main(String[] args) throws Exception {
    String userId = "";
    Boolean isTest = false;//from  ww w.  ja v a2 s .com
    Date startDate = null;
    Date endDate = null;

    SimpleDateFormat dtFormat = new SimpleDateFormat("yyyyMMdd");

    CommandLineParser parser = new DefaultParser();

    BialxOptions options = new BialxOptions();

    // Parse the program arguments
    CommandLine commandLine = parser.parse(options, args);

    // optional values
    if (commandLine.hasOption('s')) {
        startDate = dtFormat.parse(commandLine.getOptionValue('s'));
    }

    if (commandLine.hasOption('e')) {
        endDate = dtFormat.parse(commandLine.getOptionValue('e'));
    }

    if (commandLine.hasOption('t')) {
        isTest = true;
    }

    FDL fdl;
    PasswordCallback pwdHandler;
    Product product;

    fdl = new FDL();

    pwdHandler = new UserPasswordHandler(userId, CERT_PASSWORD);

    product = new Product("Bial-x EBICS FDL", Locale.FRANCE, null);

    if (commandLine.hasOption(BialxOptions.OPTION_CREATION)
            && !commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) {
        if (options.checkCreationOptions(commandLine)) {
            CreationOptions co = options.loadCreationOptions(commandLine);
            fdl.configuration.getLogger().info(String.format("Banque : %s", co.getBankName()));
            fdl.configuration.getLogger().info(String.format("Host : %s", co.getHostId()));
            fdl.configuration.getLogger().info(String.format("URL : %s", co.getBankUrl()));
            fdl.configuration.getLogger().info(String.format("Partner : %s", co.getPartnerId()));
            fdl.configuration.getLogger().info(String.format("User : %s", co.getUserId()));
            User user = fdl.createUser(co.getUserId(), co.getHostId(), co.getPartnerId(), co.getBankName(),
                    co.getBankUrl(), pwdHandler);
            fdl.sendHPBRequest(user, product);
        } else {
            fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande.");
            System.exit(0);
        }
    }

    if (!commandLine.hasOption(BialxOptions.OPTION_CREATION)
            && commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)) {
        if (options.checkDownloadOptions(commandLine)) {
            DownloadOptions dop = options.loadDownloadOptions(commandLine);
            fdl.configuration.getLogger().info(String.format("Banque : %s", dop.getHostId()));
            fdl.configuration.getLogger().info(String.format("Host : %s", dop.getHostId()));
            fdl.configuration.getLogger().info(String.format("Partner : %s", dop.getPartnerId()));
            fdl.configuration.getLogger().info(String.format("User : %s", dop.getUserId()));
            fdl.configuration.getLogger().info(String.format("Format : %s", dop.getFormat()));
            fdl.configuration.getLogger().info(String.format("Destination : %s", dop.getDestination()));
            if (startDate != null) {
                fdl.configuration.getLogger()
                        .info(String.format("Date dbut : %s", dtFormat.format(startDate)));
            }
            if (endDate != null) {
                fdl.configuration.getLogger().info(String.format("Date fin : %s", dtFormat.format(endDate)));
            }
            fdl.loadUser(dop.getHostId(), dop.getPartnerId(), dop.getUserId(), pwdHandler);
            fdl.fetchFile(dop.getDestination(), dop.getUserId(), dop.getFormat(), product, OrderType.FDL,
                    isTest, startDate, endDate);
        } else {
            fdl.configuration.getLogger().info("Vrifiez les paramtres de la commande.");
            System.exit(0);
        }
    }

    if (commandLine.hasOption(BialxOptions.OPTION_DOWNLOAD)
            && commandLine.hasOption(BialxOptions.OPTION_CREATION)) {
        fdl.configuration.getLogger().error("Impossible d'avoir les options C et D dans la mme commande.");
        System.exit(0);
    }

    fdl.quit();
}

From source file:com.adobe.aem.demomachine.Json2Csv.java

public static void main(String[] args) throws IOException {

    String inputFile1 = null;//w w  w  .  j a v a  2 s  .co  m
    String inputFile2 = null;
    String outputFile = null;

    HashMap<String, String> hmReportSuites = new HashMap<String, String>();

    // Command line options for this tool
    Options options = new Options();
    options.addOption("c", true, "Filename 1");
    options.addOption("r", true, "Filename 2");
    options.addOption("o", true, "Filename 3");
    CommandLineParser parser = new BasicParser();
    try {
        CommandLine cmd = parser.parse(options, args);

        if (cmd.hasOption("c")) {
            inputFile1 = cmd.getOptionValue("c");
        }

        if (cmd.hasOption("r")) {
            inputFile2 = cmd.getOptionValue("r");
        }

        if (cmd.hasOption("o")) {
            outputFile = cmd.getOptionValue("o");
        }

        if (inputFile1 == null || inputFile1 == null || outputFile == null) {
            System.exit(-1);
        }

    } catch (ParseException ex) {

        logger.error(ex.getMessage());

    }

    // List of customers and report suites for these customers
    String sInputFile1 = readFile(inputFile1, Charset.defaultCharset());
    sInputFile1 = sInputFile1.replaceAll("ObjectId\\(\"([0-9a-z]*)\"\\)", "\"$1\"");

    // Processing the list of report suites for each customer
    try {

        JSONArray jCustomers = new JSONArray(sInputFile1.trim());
        for (int i = 0, size = jCustomers.length(); i < size; i++) {
            JSONObject jCustomer = jCustomers.getJSONObject(i);
            Iterator<?> keys = jCustomer.keys();
            String companyName = null;
            while (keys.hasNext()) {
                String key = (String) keys.next();
                if (key.equals("company")) {
                    companyName = jCustomer.getString(key);
                }
            }
            keys = jCustomer.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();

                if (key.equals("report_suites")) {
                    JSONArray jReportSuites = jCustomer.getJSONArray(key);
                    for (int j = 0, rSize = jReportSuites.length(); j < rSize; j++) {
                        hmReportSuites.put(jReportSuites.getString(j), companyName);
                        System.out.println(jReportSuites.get(j) + " for company " + companyName);
                    }

                }
            }
        }

        // Creating the out put file
        PrintWriter writer = new PrintWriter(outputFile, "UTF-8");
        writer.println("\"" + "Customer" + "\",\"" + "ReportSuite ID" + "\",\"" + "Number of Documents"
                + "\",\"" + "Last Updated" + "\"");

        // Processing the list of SOLR collections
        String sInputFile2 = readFile(inputFile2, Charset.defaultCharset());
        sInputFile2 = sInputFile2.replaceAll("NumberLong\\(\"([0-9a-z]*)\"\\)", "\"$1\"");

        JSONObject jResults = new JSONObject(sInputFile2.trim());
        JSONArray jCollections = jResults.getJSONArray("result");
        for (int i = 0, size = jCollections.length(); i < size; i++) {
            JSONObject jCollection = jCollections.getJSONObject(i);
            String id = null;
            String number = null;
            String lastupdate = null;

            Iterator<?> keys = jCollection.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                if (key.equals("_id")) {
                    id = jCollection.getString(key);
                }
            }

            keys = jCollection.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                if (key.equals("noOfDocs")) {
                    number = jCollection.getString(key);
                }
            }

            keys = jCollection.keys();
            while (keys.hasNext()) {
                String key = (String) keys.next();
                if (key.equals("latestUpdateDate")) {
                    lastupdate = jCollection.getString(key);
                }
            }

            Date d = new Date(Long.parseLong(lastupdate));
            System.out.println(hmReportSuites.get(id) + "," + id + "," + number + "," + lastupdate + ","
                    + new SimpleDateFormat("MM-dd-yyyy").format(d));
            writer.println("\"" + hmReportSuites.get(id) + "\",\"" + id + "\",\"" + number + "\",\""
                    + new SimpleDateFormat("MM-dd-yyyy").format(d) + "\"");

        }

        writer.close();

    } catch (JSONException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }

}

From source file:edu.cmu.lti.oaqa.knn4qa.apps.LuceneIndexer.java

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

    options.addOption(CommonParams.ROOT_DIR_PARAM, null, true, CommonParams.ROOT_DIR_DESC);
    options.addOption(CommonParams.SUB_DIR_TYPE_PARAM, null, true, CommonParams.SUB_DIR_TYPE_DESC);
    options.addOption(CommonParams.MAX_NUM_REC_PARAM, null, true, CommonParams.MAX_NUM_REC_DESC);
    options.addOption(CommonParams.SOLR_FILE_NAME_PARAM, null, true, CommonParams.SOLR_FILE_NAME_DESC);
    options.addOption(CommonParams.OUT_INDEX_PARAM, null, true, CommonParams.OUT_MINDEX_DESC);

    CommandLineParser parser = new org.apache.commons.cli.GnuParser();

    try {/*  ww  w.  j  a v a  2s.  c  o  m*/
        CommandLine cmd = parser.parse(options, args);

        String rootDir = null;

        rootDir = cmd.getOptionValue(CommonParams.ROOT_DIR_PARAM);

        if (null == rootDir)
            Usage("Specify: " + CommonParams.ROOT_DIR_DESC, options);

        String outputDirName = cmd.getOptionValue(CommonParams.OUT_INDEX_PARAM);

        if (null == outputDirName)
            Usage("Specify: " + CommonParams.OUT_MINDEX_DESC, options);

        String subDirTypeList = cmd.getOptionValue(CommonParams.SUB_DIR_TYPE_PARAM);

        if (null == subDirTypeList || subDirTypeList.isEmpty())
            Usage("Specify: " + CommonParams.SUB_DIR_TYPE_DESC, options);

        String solrFileName = cmd.getOptionValue(CommonParams.SOLR_FILE_NAME_PARAM);
        if (null == solrFileName)
            Usage("Specify: " + CommonParams.SOLR_FILE_NAME_DESC, options);

        int maxNumRec = Integer.MAX_VALUE;

        String tmp = cmd.getOptionValue(CommonParams.MAX_NUM_REC_PARAM);

        if (tmp != null) {
            try {
                maxNumRec = Integer.parseInt(tmp);
                if (maxNumRec <= 0) {
                    Usage("The maximum number of records should be a positive integer", options);
                }
            } catch (NumberFormatException e) {
                Usage("The maximum number of records should be a positive integer", options);
            }
        }

        File outputDir = new File(outputDirName);
        if (!outputDir.exists()) {
            if (!outputDir.mkdirs()) {
                System.out.println("couldn't create " + outputDir.getAbsolutePath());
                System.exit(1);
            }
        }
        if (!outputDir.isDirectory()) {
            System.out.println(outputDir.getAbsolutePath() + " is not a directory!");
            System.exit(1);
        }
        if (!outputDir.canWrite()) {
            System.out.println("Can't write to " + outputDir.getAbsolutePath());
            System.exit(1);
        }

        String subDirs[] = subDirTypeList.split(",");

        int docNum = 0;

        // No English analyzer here, all language-related processing is done already,
        // here we simply white-space tokenize and index tokens verbatim.
        Analyzer analyzer = new WhitespaceAnalyzer();
        FSDirectory indexDir = FSDirectory.open(outputDir);
        IndexWriterConfig indexConf = new IndexWriterConfig(analyzer.getVersion(), analyzer);

        System.out.println("Creating a new Lucene index, maximum # of docs to process: " + maxNumRec);
        indexConf.setOpenMode(OpenMode.CREATE);
        IndexWriter indexWriter = new IndexWriter(indexDir, indexConf);

        for (int subDirId = 0; subDirId < subDirs.length && docNum < maxNumRec; ++subDirId) {
            String inputFileName = rootDir + "/" + subDirs[subDirId] + "/" + solrFileName;

            System.out.println("Input file name: " + inputFileName);

            BufferedReader inpText = new BufferedReader(
                    new InputStreamReader(CompressUtils.createInputStream(inputFileName)));
            String docText = XmlHelper.readNextXMLIndexEntry(inpText);

            for (; docText != null && docNum < maxNumRec; docText = XmlHelper.readNextXMLIndexEntry(inpText)) {
                ++docNum;
                Map<String, String> docFields = null;

                Document luceneDoc = new Document();

                try {
                    docFields = XmlHelper.parseXMLIndexEntry(docText);
                } catch (Exception e) {
                    System.err.println(String.format("Parsing error, offending DOC #%d:\n%s", docNum, docText));
                    System.exit(1);
                }

                String id = docFields.get(UtilConst.TAG_DOCNO);

                if (id == null) {
                    System.err.println(String.format("No ID tag '%s', offending DOC #%d:\n%s",
                            UtilConst.TAG_DOCNO, docNum, docText));
                }

                luceneDoc.add(new StringField(UtilConst.TAG_DOCNO, id, Field.Store.YES));

                for (Map.Entry<String, String> e : docFields.entrySet())
                    if (!e.getKey().equals(UtilConst.TAG_DOCNO)) {
                        luceneDoc.add(new TextField(e.getKey(), e.getValue(), Field.Store.YES));
                    }
                indexWriter.addDocument(luceneDoc);
                if (docNum % 1000 == 0)
                    System.out.println("Indexed " + docNum + " docs");
            }
            System.out.println("Indexed " + docNum + " docs");
        }

        indexWriter.commit();
        indexWriter.close();

    } catch (ParseException e) {
        Usage("Cannot parse arguments", options);
    } catch (Exception e) {
        System.err.println("Terminating due to an exception: " + e);
        System.exit(1);
    }

}

From source file:edu.msu.cme.rdp.alignment.errorcheck.RmPartialSeqs.java

/**
* This program detects partial sequences based on the best pairwise alignment for each query sequence, 
* @param args//from w w  w.  ja  va  2  s . c  om
* @throws Exception 
*/
public static void main(String[] args) throws Exception {

    String trainseqFile = null;
    String queryFile = null;
    PrintStream seqOutStream = null;
    PrintStream alignOutStream = null;
    AlignmentMode mode = AlignmentMode.overlap;
    int k = 10;
    int min_gaps = 50;

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

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

        if (line.hasOption("min_gaps")) {
            min_gaps = Integer.parseInt(line.getOptionValue("min_gaps"));
        }
        if (line.hasOption("knn")) {
            k = Integer.parseInt(line.getOptionValue("knn"));
        }
        if (line.hasOption("alignment-out")) {
            alignOutStream = new PrintStream(new File(line.getOptionValue("alignment-out")));
        }
        args = line.getArgs();
        if (args.length != 3) {
            throw new Exception("wrong number of arguments");
        }

        trainseqFile = args[0];
        queryFile = args[1];
        seqOutStream = new PrintStream(new File(args[2]));
    } catch (Exception e) {
        System.err.println("Error: " + e.getMessage());
        new HelpFormatter().printHelp(80,
                " [options] fulllengthSeqFile queryFile passedSeqOutFile\n  sequences can be either protein or nucleotide",
                "", options, "");
        return;
    }

    RmPartialSeqs theObj = new RmPartialSeqs(trainseqFile, queryFile, mode, k, min_gaps);

    theObj.checkPartial(seqOutStream, alignOutStream);
}

From source file:de.uni_koblenz.jgralab.utilities.greqlserver.GReQLConsole.java

/**
 * Performs some queries, extend this method to perform more queries
 * /* ww  w .j  a v a  2s  .  c o  m*/
 * @param args
 */
public static void main(String[] args) {
    try {
        CommandLine comLine = processCommandLineOptions(args);
        assert comLine != null;

        String queryFile = comLine.getOptionValue("q");
        String graphFile = comLine.getOptionValue("g");
        boolean loadSchema = comLine.hasOption("s");

        JGraLab.setLogLevel(Level.SEVERE);
        GReQLConsole console = new GReQLConsole(graphFile, loadSchema, comLine.hasOption('v'));
        Object result = console.performQuery(new File(queryFile));

        if (comLine.hasOption("o")) {
            console.saveResultToFile(result, comLine.getOptionValue("o"), comLine.getOptionValue('t'));
        } else {
            System.out.println("Result: " + result);
        }
    } catch (Exception e) {
        if (e instanceof ParsingException) {
            ParsingException ex = (ParsingException) e;
            System.err.println("##exception=ParsingException");
            System.err.println("##offset=" + ex.getOffset());
            System.err.println("##length=" + ex.getLength());
        } else if (e instanceof QuerySourceException) {
            QuerySourceException ex = (QuerySourceException) e;
            System.err.println("##exception=" + ex.getClass().getSimpleName());
            System.err.println("##offset=" + ex.getOffset());
            System.err.println("##length=" + ex.getLength());
        }
        e.printStackTrace();
        System.exit(1); // exit with non-zero exit code
    }
}

From source file:com.nexmo.client.examples.TestVoiceCall.java

public static void main(String[] argv) throws Exception {
    Options options = new Options().addOption("v", "Verbosity")
            .addOption("f", "from", true, "Phone number to call from")
            .addOption("t", "to", true, "Phone number to call")
            .addOption("h", "webhook", true, "URL to call for instructions");
    CommandLineParser parser = new DefaultParser();

    CommandLine cli;
    try {//  ww  w  .j av  a  2 s.  com
        cli = parser.parse(options, argv);
    } catch (ParseException exc) {
        System.err.println("Parsing failed: " + exc.getMessage());
        System.exit(128);
        return;
    }

    Queue<String> args = new LinkedList<String>(cli.getArgList());
    String from = cli.getOptionValue("f");
    String to = cli.getOptionValue("t");
    System.out.println("From: " + from);
    System.out.println("To: " + to);

    NexmoClient client = new NexmoClient(new JWTAuthMethod("951614e0-eec4-4087-a6b1-3f4c2f169cb0",
            FileSystems.getDefault().getPath("valid_application_key.pem")));
    client.getVoiceClient().createCall(
            new Call(to, from, "https://nexmo-community.github.io/ncco-examples/first_call_talk.json"));
}