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:org.apache.accumulo.shell.commands.OptUtil.java

public static Option tableOpt(final String description) {
    final Option tableOpt = new Option(ShellOptions.tableOption, "table", true, description);
    tableOpt.setArgName("table");
    tableOpt.setRequired(false);
    return tableOpt;
}

From source file:org.apache.accumulo.shell.commands.OptUtil.java

public static Option namespaceOpt(final String description) {
    final Option namespaceOpt = new Option(ShellOptions.namespaceOption, "namespace", true, description);
    namespaceOpt.setArgName("namespace");
    namespaceOpt.setRequired(false);
    return namespaceOpt;
}

From source file:org.apache.activemq.apollo.util.cli.OptionBuilder.java

public Option op() {
    Option option = new Option(id != null ? id : " ", description);
    option.setLongOpt(name);//from w w w . ja  va2s .c  om
    option.setRequired(required);
    option.setOptionalArg(optional);
    option.setType(type);
    option.setValueSeparator(sperator);
    if (arg != null && args == -1) {
        args = 1;
    }
    option.setArgs(args);
    option.setArgName(arg);
    return option;
}

From source file:org.apache.ambari.servicemonitor.clients.BaseClient.java

private void addToolOptions(Options options, boolean confRequired) {
    //conf is required
    Option option = OptionHelper.addStringArgOpt(options, "cf", "conf", "configuration file");
    option.setType(PatternOptionBuilder.FILE_VALUE);
    option.setRequired(confRequired);
    OptionHelper.addStringArgOpt(options, "fs", "filesystem", "filesystem to use");
    OptionHelper.addStringArgOpt(options, "jt", "jobtracker", "job tracker to connect to");
}

From source file:org.apache.ambari.servicemonitor.clients.LsDir.java

@Override
protected Options createChildOptions(Options options) {
    Option option = new Option("d", "dir", true, "directory");
    option.setRequired(true);
    options.addOption(option);// w  ww . ja  v a  2  s  . co  m
    return options;
}

From source file:org.apache.atlas.Atlas.java

protected static CommandLine parseArgs(String[] args) throws ParseException {
    Options options = new Options();
    Option opt;

    opt = new Option(APP_PATH, true, "Application Path");
    opt.setRequired(false);
    options.addOption(opt);/*w w w .  jav  a 2s .  c o  m*/

    opt = new Option(APP_PORT, true, "Application Port");
    opt.setRequired(false);
    options.addOption(opt);

    return new GnuParser().parse(options, args);
}

From source file:org.apache.blur.shell.ExecutePlatformCommandCommand.java

private void addOptions(boolean required, Options options, Set<Entry<String, ArgumentDescriptor>> entrySet) {
    for (Entry<String, ArgumentDescriptor> e : entrySet) {
        String argumentName = e.getKey();
        ArgumentDescriptor argumentDescriptor = e.getValue();
        Option option = OptionBuilder.create(argumentName);
        option.setRequired(required);
        String description = argumentDescriptor.getDescription();
        option.setDescription(createDescription(description, required));
        option.setArgs(1);/*from  ww  w  .ja va  2  s  .c  o  m*/
        options.addOption(option);
    }
}

From source file:org.apache.cocoon.portal.pluto.Deploy.java

public static void main(String args[]) {
    String warFile;//from  ww w.  ja va2s. co m
    String webAppsDir;

    final Options options = new Options();

    Option o;
    o = new Option("w", true, "webapps directory");
    o.setRequired(true);
    o.setArgName("WEBAPPS_DIR");
    options.addOption(o);

    o = new Option("p", true, "web archive containing the portlet(s)");
    o.setRequired(true);
    o.setArgName("PORTLET_WAR");
    options.addOption(o);

    options.addOption("d", "debug", false, "Show debug messages.");

    try {
        final CommandLineParser parser = new PosixParser();
        final CommandLine cmd = parser.parse(options, args);

        // first test/turn on debug
        debug = cmd.hasOption("d");
        if (debug) {
            for (int i = 0; i < args.length; i++) {
                System.out.println("args[" + i + "]:" + args[i]);
            }
        }

        webAppsDir = cmd.getOptionValue("w");
        if (!webAppsDir.endsWith(File.separator))
            webAppsDir += File.separatorChar;

        //portalImplWebDir = cmd.getOptionValue("X");
        //if (!portalImplWebDir.endsWith(File.separator))
        //    portalImplWebDir += File.separatorChar;

        warFile = cmd.getOptionValue("p");
    } catch (ParseException exp) {
        HelpFormatter formatter = new HelpFormatter();
        formatter.printHelp("deploy", options, true);
        System.exit(1);
        return;
    }

    // let's do some tests on the war file name
    String warFileName = warFile;
    if (warFileName.indexOf("/") != -1) {
        warFileName = warFileName.substring(warFileName.lastIndexOf("/") + 1);
    }
    if (warFileName.indexOf(File.separatorChar) != -1) {
        warFileName = warFileName.substring(warFileName.lastIndexOf(File.separatorChar) + 1);
    }
    if (warFileName.endsWith(".war")) {
        warFileName = warFileName.substring(0, warFileName.lastIndexOf("."));
    }

    try {
        deployArchive(webAppsDir, warFile, warFileName);

        prepareWebArchive(webAppsDir, warFileName);
    } catch (Exception e) {
        e.printStackTrace();
        System.exit(1);
        return;
    }
    System.exit(0);
}

From source file:org.apache.ctakes.jdl.AppMain.java

/**
 * @return the options of the commandLine
 *///  www  .j  av a2 s .c o m
public static Options getOprions() {
    Option optXdlConn = new Option(OPT_XDL_CONN, OPT_XDL_CONN_LONG, true, OPT_XDL_CONN_DESCR);
    optXdlConn.setRequired(true);
    Option optXdlData = new Option(OPT_XDL_DATA, OPT_XDL_DATA_LONG, true, OPT_XDL_DATA_DESCR);
    optXdlData.setRequired(true);
    Options options = new Options();
    options.addOption(optXdlConn);
    options.addOption(optXdlData);
    options.addOption(OPT_XDL_LOAD, OPT_XDL_LOAD_LONG, true, OPT_XDL_LOAD_DESCR);
    return options;
}

From source file:org.apache.directory.server.tools.commands.exportcmd.ExportCommandCL.java

public Options getOptions() {
    Options opts = new Options();
    Option op = new Option("h", "host", true, "server host: defaults to localhost");
    op.setRequired(false);
    opts.addOption(op);/*from   w  w w.ja v  a 2 s. c om*/
    op = new Option("p", "port", true, "server port: defaults to 10389 or server.xml specified port");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("u", "user", true, "the user: default to uid=admin, ou=system");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("w", "password", true, "the apacheds administrator's password: defaults to secret");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("a", "auth", true, "the authentication mode: defaults to 'simple'");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("b", "base-dn", true, "the base DN: defaults to ''");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("e", "exportpoint", true, "the export point: defaults to ''");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("s", "scope", true, "the export scope ('" + SCOPE_OBJECT + "', '" + SCOPE_ONELEVEL
            + "' or '" + SCOPE_SUBTREE + "'): defaults to '" + SCOPE_SUBTREE + "'");
    op.setRequired(false);
    opts.addOption(op);
    op = new Option("f", "file", true, "the ldif file to export data to");
    op.setRequired(true);
    opts.addOption(op);

    return opts;
}