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:de.topobyte.utilities.apache.commons.cli.OptionHelper.java

/**
 * Add a short option to the options specified by parameters
 * /*from   w w w  .  j  a  v  a  2  s .c om*/
 * @param options
 *            the options to add to.
 * @param opt
 *            the short option name.
 * @param hasArg
 *            whether it expects an argument
 * @param required
 *            whether this is a required option.
 * @param description
 *            the option description
 * @return the Option object created.
 */
public static Option addS(Options options, String opt, boolean hasArg, boolean required, String description) {
    Option option = new Option(opt, hasArg, description);
    option.setRequired(required);
    options.addOption(option);
    return option;
}

From source file:de.oth.keycloak.util.CheckParams.java

private static Option createOption(String shortS, String longS, boolean args, String descr, boolean required) {
    Option o = new Option(shortS, longS, args, descr);
    o.setRequired(required);
    return o;//from  w  ww  .j a v a 2  s. co m
}

From source file:de.topobyte.utilities.apache.commons.cli.OptionHelper.java

/**
 * Add a short option to the options specified by parameters
 * /*w w w.  ja  v a  2 s.  c  o m*/
 * @param options
 *            the options to add to.
 * @param opt
 *            the short option name.
 * @param hasArg
 *            whether it expects an argument
 * @param required
 *            whether this is a required option.
 * @param argName
 *            the name of the argument.
 * @param description
 *            the option description
 * @return the Option object created.
 */
public static Option addS(Options options, String opt, boolean hasArg, boolean required, String argName,
        String description) {
    Option option = new Option(opt, hasArg, description);
    option.setRequired(required);
    option.setArgName(argName);
    options.addOption(option);
    return option;
}

From source file:com.alibaba.rocketmq.filtersrv.FiltersrvStartup.java

public static Options buildCommandlineOptions(final Options options) {
    Option opt = new Option("c", "configFile", true, "Filter server config properties file");
    opt.setRequired(false);
    options.addOption(opt);/*from ww  w . j  a  v  a2 s .  co m*/

    opt = new Option("p", "printConfigItem", false, "Print all config item");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.aliyun.openservices.odps.console.resource.ListFunctionsCommand.java

static Options initOptions() {
    Options opts = new Options();
    Option project_name = new Option("p", true, "project name");

    project_name.setRequired(false);

    opts.addOption(project_name);//w  w  w. j a  v  a2 s  . com

    return opts;
}

From source file:com.alibaba.rocketmq.example.benchmark.Consumer.java

public static Options buildCommandlineOptions(final Options options) {
    Option opt = new Option("t", "topic", true, "Topic name, Default: BenchmarkTest");
    opt.setRequired(false);
    options.addOption(opt);/*  w  w  w.  jav a  2  s  .  c  o  m*/

    opt = new Option("g", "group", true, "Consumer group name, Default: benchmark_consumer");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("p", "group prefix enable", true, "Consumer group name, Default: false");
    opt.setRequired(false);
    options.addOption(opt);

    return options;
}

From source file:com.knewton.mapreduce.cassandra.WriteSampleSSTable.java

/**
 * Setup the options used by the random student event generator.
 *
 * @return//from w  ww  .  j a va2  s  . c o  m
 */
private static Options buildOptions() {
    Options options = new Options();
    Option option = new Option("s", "students", true,
            "The number of students (rows) to be generated. Default value is 100.");
    option.setRequired(false);
    options.addOption(option);
    option = new Option("e", "studentEvents", true,
            "The number of student events per student to be generated. Default value is 10");
    option.setRequired(false);
    options.addOption(option);
    option = new Option("h", "help", false, "Prints this help message.");
    option.setRequired(false);
    options.addOption(option);
    return options;
}

From source file:de.topobyte.utilities.apache.commons.cli.OptionHelper.java

/**
 * Add an option to the options specified by parameters
 * /*from ww  w . java 2s . c  o  m*/
 * @param options
 *            the options to add to.
 * @param opt
 *            the short option name.
 * @param longName
 *            the long option name.
 * @param hasArg
 *            whether it expects an argument
 * @param required
 *            whether this is a required option.
 * @param description
 *            the option description
 * @return the Option object created.
 */
public static Option add(Options options, String opt, String longName, boolean hasArg, boolean required,
        String description) {
    Option option = new Option(opt, longName, hasArg, description);
    option.setRequired(required);
    options.addOption(option);
    return option;
}

From source file:de.topobyte.utilities.apache.commons.cli.OptionHelper.java

/**
 * Add a long option to the options specified by parameters
 * /*from   w w  w  .j a v a2 s  .  co  m*/
 * @param options
 *            the options to add to.
 * @param longName
 *            the long option name.
 * @param hasArg
 *            whether it expects an argument
 * @param required
 *            whether this is a required option.
 * @param description
 *            the option description
 * @return the Option object created.
 */
public static Option addL(Options options, String longName, boolean hasArg, boolean required,
        String description) {
    Option option = new Option(null, longName, hasArg, description);
    option.setRequired(required);
    options.addOption(option);
    return option;
}

From source file:de.topobyte.utilities.apache.commons.cli.OptionHelper.java

/**
 * Add an option to the options specified by parameters
 * /*  w  ww . j  a  va2  s . c  o m*/
 * @param options
 *            the options to add to.
 * @param opt
 *            the short option name.
 * @param longName
 *            the long option name.
 * @param hasArg
 *            whether it expects an argument
 * @param required
 *            whether this is a required option.
 * @param argName
 *            the name of the argument.
 * @param description
 *            the option description
 * @return the Option object created.
 */
public static Option add(Options options, String opt, String longName, boolean hasArg, boolean required,
        String argName, String description) {
    Option option = new Option(opt, longName, hasArg, description);
    option.setRequired(required);
    option.setArgName(argName);
    options.addOption(option);
    return option;
}