Example usage for org.apache.commons.cli OptionBuilder isRequired

List of usage examples for org.apache.commons.cli OptionBuilder isRequired

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder isRequired.

Prototype

public static OptionBuilder isRequired() 

Source Link

Document

The next Option created will be required.

Usage

From source file:eu.crydee.alignment.aligner.VideoLecturesP.java

static private Params parseArguments(String[] args) throws ParseException {
    Options shortCircuitOptions = new Options();
    shortCircuitOptions/*from  w w  w .  j av a  2s. com*/
            .addOption(OptionBuilder.withLongOpt("help").withDescription("Print this message.").create('h'));
    shortCircuitOptions
            .addOption(OptionBuilder.withLongOpt("version").withDescription("Print the version.").create('v'));
    Options options = new Options();
    options.addOption(OptionBuilder.isRequired().withLongOpt("tei").hasArg().withArgName("folder-path")
            .withDescription("Path to the folder of the TEI body files.").create('t'));
    options.addOption(OptionBuilder.isRequired().withLongOpt("dfxp").hasArg().withArgName("folder-path")
            .withDescription("Path to the folder of the DFXP files.").create('d'));
    CommandLineParser parser = new PosixParser();
    CommandLine cmd = parser.parse(shortCircuitOptions, args, true);
    if (cmd.hasOption('h')) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("aligner", options, true);
        System.exit(0);
    }
    if (cmd.hasOption('v')) {
        System.out.println("aligner v1.0.0-SNAPSHOT");
        System.exit(0);
    }
    cmd = parser.parse(options, args);
    return new Params(cmd.getOptionValue('t'), cmd.getOptionValue('d'));
}

From source file:com.ibm.watson.developer_cloud.professor_languo.ingestion.IngestionDriver.java

/**
 * create a CommandLine interpreter while is able to detect the options used by the user and get
 * the values of the options easily/*www .  j a  v a  2s  .  co  m*/
 * 
 * @param args - the string tokens for the command line arguments
 * @return a CommandLine interpreter while is able to detect the options used by the user and get
 *         the values of the options easily
 * @throws IngestionException
 */
@SuppressWarnings("static-access")
private static CommandLine createCmdLineInterpreter(String[] args) throws IngestionException {
    CommandLine cmdLine = null;
    CommandLineParser parser = new BasicParser();

    options.addOption("h", "help", false, Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_HELP")); //$NON-NLS-1$

    options.addOption(OptionBuilder.withLongOpt("indexStat").withArgName("index status file path").hasArg()
            .withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_INDEX_STAT")) //$NON-NLS-1$
            .create("i"));

    options.addOption(OptionBuilder.withLongOpt("queryGeneratorsStr").withArgName("query generators").hasArg()
            .withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_QUERY_GENERATORS")) //$NON-NLS-1$
            .create("q"));

    options.addOption(OptionBuilder.withLongOpt("indexDir").withArgName("index file directory path").hasArg()
            .withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_INDEX_DIR")) //$NON-NLS-1$
            .create("d"));

    options.addOption(OptionBuilder.withLongOpt("tsvDir").withArgName("duplicate thread file directory path")
            .hasArg().withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_TSV_DIR")) //$NON-NLS-1$
            .create("v"));

    options.addOption(OptionBuilder.withLongOpt("uniqDir").withArgName("unique thread file directory path")
            .hasArg().withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_UNIQUE_DIR")) //$NON-NLS-1$
            .create("u"));

    options.addOption(OptionBuilder.withLongOpt("resDir").withArgName(
            "The directory path for by products generated by the application(e.g. index file, stats, csv file for dupthreads)")
            .hasArg().withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_RES_DIR")) //$NON-NLS-1$
            .create("r"));

    options.addOption(OptionBuilder.withLongOpt("caAnswerNum")
            .withArgName("The number of candidate answers returned by the candidate answer generator").hasArg()
            .withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_CANDIDATE_ANSWER_NUM")) //$NON-NLS-1$
            .create("b"));

    options.addOption(OptionBuilder.isRequired().withLongOpt("configure").withArgName("configuration file name")
            .hasArg().withDescription(Messages.getString("RetrieveAndRank.CLI_DESCRIPTION_CONFIGURE")) //$NON-NLS-1$
            .create("c"));
    try {
        cmdLine = parser.parse(options, args);
    } catch (ParseException e) {
        throw new IngestionException(e);
    }

    return cmdLine;
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createPortfolioNameOption() {
    OptionBuilder.withLongOpt("portfolio");
    OptionBuilder.withDescription("The name of the portfolio to create/update");
    OptionBuilder.hasArg();/*w  w  w .  j av  a 2  s.  c o  m*/
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();
    return OptionBuilder.create(PORTFOLIO_NAME_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createOptionDepthOption() {
    OptionBuilder.withLongOpt("depth");
    OptionBuilder.withDescription("Number of options on either side of the strike price");
    OptionBuilder.hasArg();//from w w w.ja  va2 s . c om
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();
    return OptionBuilder.create(OPTION_DEPTH_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createNumContractsOption() {
    OptionBuilder.withLongOpt("contracts");
    OptionBuilder.withDescription("Number of contracts for each option");
    OptionBuilder.hasArg();//from w  w w  .  j ava2  s.  co m
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();
    return OptionBuilder.create(NUM_CONTRACTS_OPT);
}

From source file:com.opengamma.bloombergexample.loader.DemoEquityOptionCollarPortfolioLoader.java

private static Option createNumMembersOption() {
    OptionBuilder.withLongOpt("members");
    OptionBuilder.withDescription("Number underlyers from index to include");
    OptionBuilder.hasArg();//from   w  w  w .j av  a2s .  c om
    OptionBuilder.withArgName("resource");
    OptionBuilder.isRequired();
    return OptionBuilder.create(NUM_INDEX_MEMBERS_OPT);
}

From source file:norbert.mynemo.ui.ImportCommandParser.java

private static Options getOptions() {
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();//from  ww  w . ja v  a  2s . c o  m
    OptionBuilder.withArgName(OUT_ARG_NAME);
    OptionBuilder.withDescription(OUT_DESCRIPTION);
    OptionBuilder.withLongOpt(OUT_LONG_OPTION);
    Option out = OptionBuilder.create(OUT_CHAR_OPTION);

    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withArgName(RATINGS_ARG_NAME);
    OptionBuilder.withLongOpt(RATINGS_LONG_OPTION);
    OptionBuilder.withDescription(RATINGS_DESCRIPTION);
    Option ratings = OptionBuilder.create(RATINGS_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MOVIES_ARG_NAME);
    OptionBuilder.withLongOpt(MOVIES_LONG_OPTION);
    OptionBuilder.withDescription(MOVIES_DESCRIPTION);
    Option movies = OptionBuilder.create(MOVIES_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_ARG_NAME);
    OptionBuilder.withLongOpt(USER_LONG_OPTION);
    OptionBuilder.withDescription(USER_DESCRIPTION);
    Option user = OptionBuilder.create(USER_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MAX_USERS_ARG_NAME);
    OptionBuilder.withLongOpt(MAX_USERS_LONG_OPTION);
    OptionBuilder.withDescription(MAX_USERS_DESCRIPTION);
    Option maxUsers = OptionBuilder.create();

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MIN_RATINGS_BY_MOVIE_ARG_NAME);
    OptionBuilder.withLongOpt(MIN_RATINGS_BY_MOVIE_LONG_OPTION);
    OptionBuilder.withDescription(MIN_RATINGS_BY_MOVIE_DESCRIPTION);
    Option minRatingsByMovie = OptionBuilder.create();

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MIN_COMMON_RATINGS_ARG_NAME);
    OptionBuilder.withLongOpt(MIN_COMMON_RATINGS_LONG_OPTION);
    OptionBuilder.withDescription(MIN_COMMON_RATINGS_DESCRIPTION);
    Option minCommonRatings = OptionBuilder.create();

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SIMILARITY_ARG_NAME);
    OptionBuilder.withLongOpt(SIMILARITY_LONG_OPTION);
    OptionBuilder.withDescription(SIMILARITY_DESCRIPTION);
    Option similarity = OptionBuilder.create(SIMILARITY_CHAR_OPTION);

    return new Options().addOption(out).addOption(ratings).addOption(movies).addOption(user).addOption(maxUsers)
            .addOption(minRatingsByMovie).addOption(minCommonRatings).addOption(similarity);
}

From source file:norbert.mynemo.ui.RecommendCommandParser.java

private static Options getOptions() {
    // algorithm option
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();//from   ww w . jav a  2 s .c  o  m
    OptionBuilder.withArgName(ALGORITHM_ARG_NAME);
    OptionBuilder.withLongOpt(ALGORITHM_LONG_OPTION);
    OptionBuilder.withDescription(ALGORITHM_DESCRIPTION);
    Option algorithm = OptionBuilder.create(ALGORITHM_CHAR_OPTION);

    // data model option
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(DATAMODEL_ARG_NAME);
    OptionBuilder.withLongOpt(DATAMODEL_LONG_OPTION);
    OptionBuilder.withDescription(DATAMODEL_DESCRIPTION);
    Option dataModel = OptionBuilder.create(DATAMODEL_CHAR_OPTION);

    // user option
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_ARG_NAME);
    OptionBuilder.withLongOpt(USER_LONG_OPTION);
    OptionBuilder.withDescription(USER_DESCRIPTION);
    Option user = OptionBuilder.create(USER_CHAR_OPTION);

    // recommendations option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(RECOMMENDATIONS_ARG_NAME);
    OptionBuilder.withLongOpt(RECOMMENDATIONS_LONG_OPTION);
    OptionBuilder.withDescription(RECOMMENDATIONS_DESCRIPTION);
    Option recommendation = OptionBuilder.create(RECOMMENDATIONS_CHAR_OPTION);

    // features option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(FEATURES_ARG_NAME);
    OptionBuilder.withLongOpt(FEATURES_LONG_OPTION);
    OptionBuilder.withDescription(FEATURES_DESCRIPTION);
    Option features = OptionBuilder.create(FEATURES_CHAR_OPTION);

    // iterations option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(ITERATIONS_ARG_NAME);
    OptionBuilder.withLongOpt(ITERATIONS_LONG_OPTION);
    OptionBuilder.withDescription(ITERATIONS_DESCRIPTION);
    Option iterations = OptionBuilder.create(ITERATIONS_CHAR_OPTION);

    // neighbors option
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(NEIGHBORS_ARG_NAME);
    OptionBuilder.withLongOpt(NEIGHBORS_LONG_OPTION);
    OptionBuilder.withDescription(NEIGHBORS_DESCRIPTION);
    Option neighbors = OptionBuilder.create(NEIGHBORS_CHAR_OPTION);

    return new Options().addOption(algorithm).addOption(dataModel).addOption(user).addOption(neighbors)
            .addOption(recommendation).addOption(features).addOption(iterations);
}

From source file:norbert.mynemo.ui.ScrapeCommandParser.java

private static Options getOptions() {
    // out movies
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();//from www  .  j av  a  2  s .c  o m
    OptionBuilder.withArgName(OUT_MOVIES_ARG_NAME);
    OptionBuilder.withLongOpt(OUT_MOVIES_LONG_OPTION);
    OptionBuilder.withDescription(OUT_MOVIES_DESCRIPTION);
    Option outMovies = OptionBuilder.create(OUT_MOVIES_CHAR_OPTION);

    // out ratings
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(OUT_RATINGS_ARG_NAME);
    OptionBuilder.withLongOpt(OUT_RATINGS_LONG_OPTION);
    OptionBuilder.withDescription(OUT_RATINGS_DESCRIPTION);
    Option outRatings = OptionBuilder.create(OUT_RATINGS_CHAR_OPTION);

    // input files
    OptionBuilder.isRequired();
    OptionBuilder.hasArgs();
    OptionBuilder.withArgName(IN_ARG_NAME);
    OptionBuilder.withLongOpt(IN_LONG_OPTION);
    OptionBuilder.withDescription(IN_DESCRIPTION);
    Option in = OptionBuilder.create(IN_CHAR_OPTION);

    // user agent file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USERAGENTS_ARG_NAME);
    OptionBuilder.withLongOpt(USERAGENTS_LONG_OPTION);
    OptionBuilder.withDescription(USERAGENTS_DESCRIPTION);
    Option userAgents = OptionBuilder.create(USERAGENTS_CHAR_OPTION);

    // movie blacklist file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(MOVIE_BLACKLIST_ARG_NAME);
    OptionBuilder.withLongOpt(MOVIE_BLACKLIST_LONG_OPTION);
    OptionBuilder.withDescription(MOVIE_BLACKLIST_DESCRIPTION);
    Option movieBlacklist = OptionBuilder.create();

    // user blacklist file
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_BLACKLIST_ARG_NAME);
    OptionBuilder.withLongOpt(USER_BLACKLIST_LONG_OPTION);
    OptionBuilder.withDescription(USER_BLACKLIST_DESCRIPTION);
    Option userBlacklist = OptionBuilder.create();

    return new Options().addOption(outMovies).addOption(outRatings).addOption(in).addOption(userAgents)
            .addOption(movieBlacklist).addOption(userBlacklist);
}

From source file:norbert.mynemo.ui.SelectCommandParser.java

private static Options getOptions() {
    OptionBuilder.isRequired();
    OptionBuilder.hasArg();/*from ww  w.  j  av  a  2 s .c o m*/
    OptionBuilder.withArgName(DATAMODEL_ARG_NAME);
    OptionBuilder.withDescription(DATAMODEL_DESCRIPTION);
    OptionBuilder.withLongOpt(DATAMODEL_LONG_OPTION);
    Option dataModel = OptionBuilder.create(DATAMODEL_CHAR_OPTION);

    OptionBuilder.isRequired();
    OptionBuilder.hasArg();
    OptionBuilder.withArgName(USER_ARG_NAME);
    OptionBuilder.withLongOpt(USER_LONG_OPTION);
    OptionBuilder.withDescription(USER_DESCRIPTION);
    Option user = OptionBuilder.create(USER_CHAR_OPTION);

    OptionBuilder.hasArgs();
    OptionBuilder.withArgName(ALGORITHMS_ARG_NAME);
    OptionBuilder.withLongOpt(ALGORITHMS_LONG_OPTION);
    OptionBuilder.withDescription(ALGORITHMS_DESCRIPTION);
    Option algorithms = OptionBuilder.create(ALGORITHMS_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(METRIC_ARG_NAME);
    OptionBuilder.withLongOpt(METRIC_LONG_OPTION);
    OptionBuilder.withDescription(METRIC_DESCRIPTION);
    Option metric = OptionBuilder.create(METRIC_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(SPEED_ARG_NAME);
    OptionBuilder.withLongOpt(SPEED_LONG_OPTION);
    OptionBuilder.withDescription(SPEED_DESCRIPTION);
    Option speed = OptionBuilder.create(SPEED_CHAR_OPTION);

    OptionBuilder.hasArg();
    OptionBuilder.withArgName(COVERAGE_ARG_NAME);
    OptionBuilder.withLongOpt(COVERAGE_LONG_OPTION);
    OptionBuilder.withDescription(COVERAGE_DESCRIPTION);
    Option coverage = OptionBuilder.create(COVERAGE_CHAR_OPTION);

    return new Options().addOption(dataModel).addOption(user).addOption(algorithms).addOption(metric)
            .addOption(speed).addOption(coverage);
}