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, boolean hasArg, String description) throws IllegalArgumentException 

Source Link

Document

Creates an Option using the specified parameters.

Usage

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);/* ww  w  . ja  v a 2s . co m*/

    opts.addOption(project_name);

    return opts;
}

From source file:edu.vt.middleware.crypt.asymmetric.AsymmetricCli.java

/** {@inheritDoc} */
protected void initOptions() {
    super.initOptions();

    final Option genKeyPair = new Option(OPT_GENKEYPAIR, true, "generate key pair of size; "
            + "public key written to -out path, " + "private key written to -privkey path");
    genKeyPair.setArgName("bitsize");
    genKeyPair.setOptionalArg(false);//from  w  w w  .  ja  v  a2s.c  om

    final Option privKeyPath = new Option(OPT_PRIVKEYPATH, true, "output path of generated private key");
    privKeyPath.setArgName("filepath");

    final Option encrypt = new Option(OPT_ENCRYPT, true,
            "encrypt with X.509 DER-encoded public key or certificate");
    encrypt.setArgName("pubkeypath");
    encrypt.setOptionalArg(false);

    final Option decrypt = new Option(OPT_DECRYPT, true, "decrypt with PKCS#8 DER-encoded private key");
    decrypt.setArgName("privkeypath");
    decrypt.setOptionalArg(false);

    options.addOption(genKeyPair);
    options.addOption(privKeyPath);
    options.addOption(encrypt);
    options.addOption(decrypt);
}

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

static Options initOptions() {
    Options opts = new Options();
    Option project_name = new Option("p", true, "project name");
    Option showAllOption = new Option("l", false, "show source of resource");

    project_name.setRequired(false);//from  ww  w.j  av a2  s .  c  om
    showAllOption.setRequired(false);

    opts.addOption(project_name);
    opts.addOption(showAllOption);

    return opts;
}

From source file:edu.vt.middleware.ldap.cli.SearchOperationCli.java

/** {@inheritDoc} */
@Override//from  ww  w  . j  av a  2  s  .c  o m
protected void initOptions() {
    options.addOption(new Option(OPT_DSMLV1, false, "output results in DSML v1"));

    final Map<String, String> desc = getArgDesc(ConnectionConfig.class, SearchRequest.class);
    for (String s : ConnectionConfigPropertySource.getProperties()) {
        options.addOption(new Option(s, true, desc.get(s)));
    }
    for (String s : SearchRequestPropertySource.getProperties()) {
        options.addOption(new Option(s, true, desc.get(s)));
    }
    super.initOptions();
}

From source file:edu.vt.middleware.crypt.AbstractEncryptionCli.java

/** {@inheritDoc} */
protected void initOptions() {
    super.initOptions();

    final Option cipher = new Option(OPT_CIPHER, true, "cipher algorithm");
    cipher.setArgName("algname");
    cipher.setOptionalArg(false);// ww w.ja  v  a 2 s .  com

    final Option infile = new Option(OPT_INFILE, true, "file to encrypt/decrypt; defaults to STDIN");
    infile.setArgName("filepath");
    infile.setOptionalArg(false);

    final Option outfile = new Option(OPT_OUTFILE, true, "output file containing result; defaults to STDOUT");
    outfile.setArgName("filepath");
    outfile.setOptionalArg(false);

    final Option encoding = new Option(OPT_ENCODING, true, "ciphertext encoding format, either base64 or hex");
    encoding.setArgName("format");
    encoding.setOptionalArg(false);

    options.addOption(cipher);
    options.addOption(infile);
    options.addOption(outfile);
    options.addOption(encoding);
    options.addOption(new Option(OPT_TAIL, "tail output from operation"));
}

From source file:com.zenoss.zenpacks.zenjmx.OptionsFactory.java

/**
 * Creates an Option (which is by definition ... not required)
 * @param name the short name of the argument
 * @param hasValue set to true to indicate the option has a value
 * associated with it.  set to value if the option does not have a
 * value (e.g. --cycle or --help)//w  w  w .j  a  v  a2 s.  co m
 * @param desc a description of the option
 */
private Option createOption(String name, boolean hasValue, String desc) {
    Option option = new Option(name, hasValue, desc);
    return option;
}

From source file:com.aliyun.openservices.odps.console.commands.ShowPartitionsCommand.java

static Options initOptions() {
    Options opts = new Options();
    Option project_name = new Option("p", true, "project name");
    project_name.setRequired(false);//from  w ww  .j  ava2  s.  c o m

    opts.addOption(project_name);

    return opts;
}

From source file:cli.TestCLIParser.java

@Test
public void testCommandParserX() throws Exception {
    Option opt = new Option("o", false, "O");
    Options opts = new Options();
    opts.addOption(opt);//from   w  w w . j  a  v  a 2  s. c  om
    CLIParser parser = new CLIParser("test", new String[] {});
    parser.addCommand("c", "-X ", "(everything after '-X' are pass-through parameters)", opts, true);
    CLIParser.Command c = parser.parse("c -o -X -o c".split(" "));
    Assert.assertEquals("-X", c.getCommandLine().getArgList().get(0));
    Assert.assertEquals(3, c.getCommandLine().getArgList().size());
}

From source file:hrytsenko.gscripts.AppArgs.java

private static Option createOption(String name, String description, boolean required) {
    Option option = new Option(name, true, description);
    option.setArgs(Option.UNLIMITED_VALUES);
    option.setRequired(required);/*from www . ja v a2s .  co  m*/
    return option;
}

From source file:edu.vt.middleware.ldap.cli.AuthenticatorCli.java

/** {@inheritDoc} */
@Override/*ww  w. j  a va2s .  c o m*/
protected void initOptions() {
    options.addOption(new Option(OPT_DSMLV1, false, "output results in DSML v1"));

    final Map<String, String> desc = getArgDesc(ConnectionConfig.class, Authenticator.class,
            SearchDnResolver.class, AuthenticationRequest.class);
    for (String s : ConnectionConfigPropertySource.getProperties()) {
        options.addOption(new Option(s, true, desc.get(s)));
    }
    for (String s : AuthenticatorPropertySource.getProperties()) {
        options.addOption(new Option(s, true, desc.get(s)));
    }
    for (String s : SearchDnResolverPropertySource.getProperties()) {
        // ignore connection config property
        if (!s.equalsIgnoreCase(ConnectionConfig.class.getSimpleName())) {
            options.addOption(new Option(s, true, desc.get(s)));
        }
    }
    for (String s : AuthenticationRequestPropertySource.getProperties()) {
        options.addOption(new Option(s, true, desc.get(s)));
    }
    super.initOptions();
}