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

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

Introduction

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

Prototype

public Option(String opt, String longOpt, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

From source file:com.netscape.cmstools.tps.authenticator.AuthenticatorAddCLI.java

public void createOptions() {
    Option option = new Option(null, "input", true, "Input file containing authenticator properties.");
    option.setArgName("file");
    option.setRequired(true);/*w w  w  . ja  v  a 2  s  . c o  m*/
    options.addOption(option);
}

From source file:com.damon.rocketmq.example.operation.Producer.java

public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);/*  w  w w . j a v a2  s  .c  om*/
    options.addOption(opt);

    opt = new Option("g", "producerGroup", true, "Producer Group Name");
    opt.setRequired(true);
    options.addOption(opt);

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

    opt = new Option("a", "tags", true, "Tags Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("k", "keys", true, "Keys Name");
    opt.setRequired(true);
    options.addOption(opt);

    opt = new Option("c", "msgCount", true, "Message Count");
    opt.setRequired(true);
    options.addOption(opt);

    PosixParser parser = new PosixParser();
    HelpFormatter hf = new HelpFormatter();
    hf.setWidth(110);
    CommandLine commandLine = null;
    try {
        commandLine = parser.parse(options, args);
        if (commandLine.hasOption('h')) {
            hf.printHelp("producer", options, true);
            return null;
        }
    } catch (ParseException e) {
        hf.printHelp("producer", options, true);
        return null;
    }

    return commandLine;
}

From source file:com.github.riccardove.easyjasub.commandline.CommandLineOptionList.java

public void addOption(String opt, String longOpt, String description, String argName) {
    Option option = new Option(opt, longOpt, true, description);
    option.setArgName(argName);/* www  .j a  v a2  s  . c  o m*/
    add(opt, option);
}

From source file:net.sourceforge.metware.binche.execs.CommandLineMain.java

public CommandLineMain(String[] args) {

    setupOptions();//from   w  w w.  j a v  a2  s. co  m

    for (Option opt : this) {
        options.addOption(opt);
    }
    options.addOption(new Option("h", "help", false, "print the help section"));

    try {
        cmdLine = parser.parse(options, args);
    } catch (ParseException ex) {
        logger.error("There was a problem parsing command line options: " + ex.getMessage());
    }

    if (cmdLine.hasOption('h') || cmdLine.hasOption("help")) {
        printHelp();
    }
}

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

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("t", "topic", true, "topic name");
    opt.setRequired(true);//from  w  w w . j a va 2  s  . com
    options.addOption(opt);

    opt = new Option("c", "clusterName", true, "delete topic from which cluster");
    opt.setRequired(true);
    options.addOption(opt);

    return options;
}

From source file:be.svlandeg.diffany.console.MetaOptions.java

/**
 * Define the options available for providing meta data (all simple flags)
 *//*w  ww  .  jav a 2  s .  com*/
private void defineOptions() {
    boolean hasArgument = false;

    options = new Options();

    options.addOption(
            new Option(versionShort, "version", hasArgument, "print the version information and exit"));
    options.addOption(new Option(helpShort, "help", hasArgument, "print this help message"));
}

From source file:com.netscape.cmstools.ca.CACertRequestFindCLI.java

public void createOptions() {
    Option option = null;//  w w  w .ja  va 2  s.  com

    // request state
    option = new Option(null, "status", true, "Request status (pending, cancelled, rejected, complete, all)");
    option.setArgName("status");
    options.addOption(option);

    // request type
    option = new Option(null, "type", true, "Request type (enrollment, renewal, revocation, all)");
    option.setArgName("type");
    options.addOption(option);

    //pagination options
    option = new Option(null, "start", true, "Page start");
    option.setArgName("start");
    options.addOption(option);

    option = new Option(null, "size", true, "Page size");
    option.setArgName("size");
    options.addOption(option);

    //search limits
    option = new Option(null, "maxResults", true, "Maximum number of results");
    option.setArgName("maxResults");
    options.addOption(option);

    option = new Option(null, "timeout", true, "Search timeout");
    option.setArgName("maxTime");
    options.addOption(option);
}

From source file:com.opengamma.integration.server.copier.CommandLineOption.java

private Options getCommandLineOption() {
    Options options = new Options();
    Option configOption = new Option("c", TOOLCONTEXT_CONFIG, true, "The tool context config file");
    configOption.setRequired(true);/* w w w .j a v  a  2s.  c  o  m*/
    options.addOption(configOption);

    Option serverUrlOption = new Option("s", SERVER, true, "The opengamma server url");
    serverUrlOption.setRequired(true);
    options.addOption(serverUrlOption);
    return options;
}

From source file:com.netscape.cmstools.tps.profile.ProfileMappingModifyCLI.java

public void createOptions() {
    Option option = new Option(null, "action", true,
            "Action: update (default), approve, reject, enable, disable.");
    option.setArgName("action");
    options.addOption(option);//from w  w w  . j a  v a2  s .com

    option = new Option(null, "input", true, "Input file containing profile mapping properties.");
    option.setArgName("file");
    options.addOption(option);
}

From source file:msgclient.MsgClient.java

public void parseArguments(String[] args) throws Exception {
    // Parse command line arguments
    Options options = new Options();

    Option server = new Option("s", "server", true, "server name");
    server.setRequired(true);/*from  ww w .jav a2s .com*/
    options.addOption(server);

    Option port = new Option("p", "port", true, "server port (default 8000)");
    port.setRequired(false);
    options.addOption(port);

    Option uname = new Option("u", "username", true, "username");
    uname.setRequired(true);
    options.addOption(uname);

    Option password = new Option("w", "password", false, "password (default is none)");
    password.setRequired(false);
    options.addOption(password);

    Option peerIdentifier = new Option("m", "peer identifier", true, "peer identifier (default is none)");
    peerIdentifier.setRequired(false);
    options.addOption(peerIdentifier);

    CommandLineParser parser = new DefaultParser();
    HelpFormatter formatter = new HelpFormatter();
    CommandLine cmd;

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("msgclient", options);

        System.exit(1);
        return;
    }

    // Optional arguments
    if (cmd.hasOption("p") == true) {
        serverPort = Integer.parseInt(cmd.getOptionValue("p"));
    } else {
        serverPort = DEFAULT_PORT;
    }

    if (cmd.hasOption("w") == true) {
        serverPassword = cmd.getOptionValue("w");
    } else {
        serverPassword = "";
    }

    if (cmd.hasOption("m") == true) {
        mPeerIdentifier = cmd.getOptionValue("m");
    } else {
        mPeerIdentifier = "";
    }

    // Required arguments
    serverName = cmd.getOptionValue("s");
    serverUsername = cmd.getOptionValue("u");
}