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

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

Introduction

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

Prototype

public void setArgName(String argName) 

Source Link

Document

Sets the display name for the argument value.

Usage

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

public static Option tableOpt(final String description) {
    final Option tableOpt = new Option(Shell.tableOption, "table", true, description);
    tableOpt.setArgName("table");
    tableOpt.setRequired(false);//from  w w  w. j ava 2  s .  c o m
    return tableOpt;
}

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

public static Option namespaceOpt(final String description) {
    final Option namespaceOpt = new Option(Shell.namespaceOption, "namespace", true, description);
    namespaceOpt.setArgName("namespace");
    namespaceOpt.setRequired(false);/*from  w  w  w . j a  va  2  s . c o m*/
    return namespaceOpt;
}

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

public static Option startRowOpt() {
    final Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (inclusive)");
    o.setArgName("begin-row");
    return o;//w  ww  .j a v a2 s  .c  om
}

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

public static Option endRowOpt() {
    final Option o = new Option(END_ROW_OPT, "end-row", true, "end row (inclusive)");
    o.setArgName("end-row");
    return o;/* ww  w. j a v  a 2s . c  o m*/
}

From source file:org.apache.accumulo.server.util.VerifyTabletAssignments.java

public static void main(String[] args) throws Exception {
    Options opts = new Options();

    Option zooKeeperInstance = new Option("z", "zooKeeperInstance", true,
            "use a zookeeper instance with the given instance name and list of zoo hosts");
    zooKeeperInstance.setArgName("name hosts");
    zooKeeperInstance.setArgs(2);//w w  w  . j a v  a2 s. co  m
    opts.addOption(zooKeeperInstance);

    Option usernameOption = new Option("u", "user", true, "username (required)");
    usernameOption.setArgName("user");
    usernameOption.setRequired(true);
    opts.addOption(usernameOption);

    Option passwOption = new Option("p", "password", true,
            "password (prompt for password if this option is missing)");
    passwOption.setArgName("pass");
    opts.addOption(passwOption);

    Option verboseOption = new Option("v", "verbose", false, "verbose mode (prints locations of tablets)");
    opts.addOption(verboseOption);

    CommandLine cl = null;
    String user = null;
    String passw = null;
    Instance instance = null;
    ConsoleReader reader = new ConsoleReader();
    try {
        cl = new BasicParser().parse(opts, args);

        if (cl.hasOption(zooKeeperInstance.getOpt())
                && cl.getOptionValues(zooKeeperInstance.getOpt()).length != 2)
            throw new MissingArgumentException(zooKeeperInstance);

        user = cl.getOptionValue(usernameOption.getOpt());
        passw = cl.getOptionValue(passwOption.getOpt());

        if (cl.hasOption(zooKeeperInstance.getOpt())) {
            String[] zkOpts = cl.getOptionValues(zooKeeperInstance.getOpt());
            instance = new ZooKeeperInstance(zkOpts[0], zkOpts[1]);
        } else {
            instance = HdfsZooInstance.getInstance();
        }

        if (passw == null)
            passw = reader.readLine(
                    "Enter current password for '" + user + "'@'" + instance.getInstanceName() + "': ", '*');
        if (passw == null) {
            reader.printNewline();
            return;
        } // user canceled

        if (cl.getArgs().length != 0)
            throw new ParseException("Unrecognized arguments: " + cl.getArgList());

    } catch (ParseException e) {
        PrintWriter pw = new PrintWriter(System.err);
        new HelpFormatter().printHelp(pw, Integer.MAX_VALUE,
                "accumulo " + VerifyTabletAssignments.class.getName(), null, opts, 2, 5, null, true);
        pw.flush();
        System.exit(1);
    }

    Connector conn = instance.getConnector(user, passw.getBytes());

    for (String table : conn.tableOperations().list())
        checkTable(user, passw, table, null, cl.hasOption(verboseOption.getOpt()));

}

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);//from www.  j a va 2 s.co m
    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);/*  w ww.  jav a 2 s .  com*/
    return namespaceOpt;
}

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

public static Option startRowOpt() {
    final Option o = new Option(START_ROW_OPT, "begin-row", true, "begin row (exclusive)");
    o.setArgName("begin-row");
    return o;//from   w w w.  j a  v  a  2  s  .c o m
}

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 v  a2s. c  o  m
    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.cocoon.portal.pluto.Deploy.java

public static void main(String args[]) {
    String warFile;//from w w  w  . j  av  a 2  s . com
    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);
}