Example usage for org.apache.commons.cli Option setRequired

List of usage examples for org.apache.commons.cli Option setRequired

Introduction

In this page you can find the example usage for org.apache.commons.cli Option setRequired.

Prototype

public void setRequired(boolean required) 

Source Link

Document

Sets whether this Option is mandatory.

Usage

From source file:com.tc.cli.CommandLineBuilder.java

public void addOption(String opt, String longOpt, boolean hasArg, String description, Class<?> type,
        boolean isRequired) {
    Option option = new Option(opt, longOpt, hasArg, description);
    option.setType(type);/*  ww  w  .  ja va2s.  c o  m*/
    option.setRequired(isRequired);
    options.addOption(option);
}

From source file:com.tc.cli.CommandLineBuilder.java

public void addOption(String opt, String longOpt, boolean hasArg, String description, Class<?> type,
        boolean isRequired, String argName) {
    Option option = new Option(opt, longOpt, hasArg, description);
    option.setType(type);/*  ww  w  .j  a  va  2 s  .  c o m*/
    option.setRequired(isRequired);
    option.setArgName(argName);

    options.addOption(option);
}

From source file:com.opengamma.integration.tool.marketdata.RedisSimulationSeriesLoaderTool.java

@Override
protected Options createOptions(boolean contextProvided) {

    Options options = super.createOptions(contextProvided);

    Option filenameOption = new Option(FILE_NAME_OPT, "filename", true,
            "The path to the file containing data to import (CSV or ZIP)");
    filenameOption.setRequired(true);
    options.addOption(filenameOption);/*ww w  .ja  va  2 s.c o m*/

    Option timeSeriesDataSourceOption = new Option(TIME_SERIES_DATASOURCE_OPT, "source", true,
            "The name of the time series data source");
    options.addOption(timeSeriesDataSourceOption);

    Option timeSeriesDataProviderOption = new Option(TIME_SERIES_DATAPROVIDER_OPT, "provider", true,
            "The name of the time series data provider");
    options.addOption(timeSeriesDataProviderOption);

    Option timeSeriesDataFieldOption = new Option(TIME_SERIES_DATAFIELD_OPT, "field", true,
            "The name of the time series data field");
    options.addOption(timeSeriesDataFieldOption);

    Option timeSeriesObservationTimeOption = new Option(TIME_SERIES_OBSERVATIONTIME_OPT, "time", true,
            "The time series observation time");
    options.addOption(timeSeriesObservationTimeOption);

    Option timeSeriesIdSchemeOption = new Option(TIME_SERIES_IDSCHEME_OPT, "scheme", true,
            "The time series ID scheme (e.g. RIC)");
    options.addOption(timeSeriesIdSchemeOption);

    Option timeSeriesDateFormatOption = new Option(TIME_SERIES_DATEFORMAT_OPT, "date", true,
            "The JodaTime date format (e.g. yyyyMMdd)");
    options.addOption(timeSeriesDateFormatOption);

    Option writeOption = new Option(WRITE_OPT, "write", false,
            "Actually persists the time series to the database if specified, otherwise pretty-prints without persisting");
    options.addOption(writeOption);

    return options;
}

From source file:com.opengamma.integration.tool.portfolio.PortfolioSaverTool.java

@Override
protected Options createOptions(boolean contextProvided) {

    Options options = super.createOptions(contextProvided);

    Option filenameOption = new Option(FILE_NAME_OPT, "filename", true,
            "The path to the file to create and export to (CSV, XLS or ZIP)");
    filenameOption.setRequired(true);
    options.addOption(filenameOption);//www  . jav a 2s  . c  om

    Option portfolioNameOption = new Option(PORTFOLIO_NAME_OPT, "name", true,
            "The name of the source OpenGamma portfolio");
    options.addOption(portfolioNameOption);

    Option writeOption = new Option(WRITE_OPT, "write", false,
            "Actually persists the portfolio to the file if specified, otherwise pretty-prints without persisting");
    options.addOption(writeOption);

    Option assetClassOption = new Option(SECURITY_TYPE_OPT, "securitytype", true,
            "The security type to export (ignored if ZIP output file is specified)");
    options.addOption(assetClassOption);

    Option verboseOption = new Option(VERBOSE_OPT, "verbose", false,
            "Displays progress messages on the terminal");
    options.addOption(verboseOption);

    Option includeTradesOption = new Option(INCLUDE_TRADES_OPT, "trades", false,
            "Generate a separate row for each trade instead of one row per position");
    options.addOption(includeTradesOption);

    return options;
}

From source file:fr.inrialpes.exmo.align.cli.CommonCLI.java

protected Option createListOption(String name, String longName, String desc, String argName, char sep) {
    Option opt = createOption(name, longName, desc);
    opt.setArgName(argName);/*from  ww  w  .  ja  va  2s . c o m*/
    opt.setValueSeparator(sep);
    opt.setRequired(true);
    opt.setArgs(-2); // Nicely undocumented!
    return opt;
}

From source file:com.googlecode.dex2jar.tools.BaseCmd.java

protected void initOptionFromClass(Class<?> clz) {
    if (clz == null) {
        return;/*from  ww w  .j av  a  2s  .  c  om*/
    } else {
        initOptionFromClass(clz.getSuperclass());
    }
    Field[] fs = clz.getDeclaredFields();
    for (Field f : fs) {
        Opt opt = f.getAnnotation(Opt.class);
        if (opt != null) {
            f.setAccessible(true);
            if (!opt.hasArg()) {
                Class<?> type = f.getType();
                if (!type.equals(boolean.class)) {
                    throw new RuntimeException(
                            "the type of " + f + " must be boolean, as it is declared as no args");
                }
                boolean b;
                try {
                    b = (Boolean) f.get(this);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                if (b) {
                    throw new RuntimeException(
                            "the value of " + f + " must be false, as it is declared as no args");
                }
            }
            Option option = new Option(opt.opt(), opt.hasArg(), opt.description());
            option.setRequired(opt.required());
            if (!"".equals(opt.longOpt())) {
                option.setLongOpt(opt.longOpt());
            }
            if (!"".equals(opt.argName())) {
                option.setArgName(opt.argName());
            }
            options.addOption(option);
            map.put(opt.opt(), f);
        }
    }
}

From source file:datascript.emit.java.JavaExtension.java

public void getOptions(org.apache.commons.cli.Options rdsOptions) {
    Option rdsOption;

    rdsOption = new Option("pkg", true,
            "\"packagename\"\tJava package name for types without a DataScript package");
    rdsOption.setRequired(false);
    rdsOptions.addOption(rdsOption);//from  w w  w  .  jav a 2 s.co  m

    rdsOption = new Option("debug", false,
            "enables throwing exceptions in equals() function, when objects are not equal");
    rdsOption.setRequired(false);
    rdsOptions.addOption(rdsOption);

    rdsOption = new Option("ignorePragma", false, "do not pass sql_pragma into generated code");
    rdsOption.setRequired(false);
    rdsOptions.addOption(rdsOption);
}

From source file:com.alibaba.rocketmq.tools.command.cluster.ClusterListSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("m", "moreStats", false, "Print more stats");
    opt.setRequired(false);
    options.addOption(opt);//from   www .ja va2  s. co m

    return options;
}

From source file:com.alibaba.rocketmq.tools.command.topic.UpdateTopicSubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("b", "brokerAddr", true, "create topic to which broker");
    opt.setRequired(false);
    options.addOption(opt);/*ww  w.j  a  v a2s .  c  o m*/

    opt = new Option("c", "clusterName", true, "create topic to which cluster");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("r", "readQueueNums", true, "set read queue nums");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("w", "writeQueueNums", true, "set write queue nums");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("p", "perm", true, "set topic's permission(2|4|6), intro[2:R; 4:W; 6:RW]");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("o", "order", true, "set topic's order(true|false");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("u", "unit", true, "is unit topic (true|false");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("s", "hasUnitSub", true, "has unit sub (true|false");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:mitm.application.djigzo.tools.ProxyManager.java

@SuppressWarnings("static-access")
private Options createCommandLineOptions() {
    Options options = new Options();

    Option getOption = OptionBuilder.create("get");
    getOption.setRequired(false);
    getOption.setDescription("Returns the proxy settings");
    options.addOption(getOption);/* w ww .  j  av  a2  s  .com*/

    Option userOption = OptionBuilder.withArgName("user").hasArg().withDescription("user").create("user");
    userOption.setRequired(false);
    options.addOption(userOption);

    Option passwordOption = OptionBuilder.withArgName("password").hasArg().withDescription("password")
            .create("password");
    passwordOption.setRequired(false);
    options.addOption(passwordOption);

    Option passwordPromptOption = OptionBuilder.withDescription("ask for password").create("pwd");
    passwordPromptOption.setRequired(false);
    options.addOption(passwordPromptOption);

    Option helpOption = OptionBuilder.withDescription("Show help").create("help");
    helpOption.setRequired(false);
    options.addOption(helpOption);

    hostOption = OptionBuilder.withArgName("host").hasArg()
            .withDescription("The host to connect to (127.0.0.1)").create("host");
    options.addOption(hostOption);

    portOption = OptionBuilder.withArgName("port").hasArg()
            .withDescription("The port to use (" + DjigzoWSDefaults.PORT + ")").create("port");
    options.addOption(portOption);

    return options;
}