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:de.longri.cachebox3.DesktopLauncher.java

private static CommandLine getCommandLine(String[] args) {
    Options options = new Options();

    Option scale = new Option("s", "scale", true, "scale factor");
    scale.setRequired(false);//from w  w  w.  j a  va 2  s .  c o  m
    options.addOption(scale);

    Option note4 = new Option("n", "note", false, "force layout for Note4");
    note4.setRequired(false);
    options.addOption(note4);

    Option gpsSimulator = new Option("g", "gps", false, "start with GPS simulator");
    gpsSimulator.setRequired(false);
    options.addOption(gpsSimulator);

    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("CacheBoxStarter", options);

        System.exit(1);
        return null;
    }
    return cmd;
}

From source file:com.alibaba.rocketmq.tools.command.message.QueryMsgByUniqueKeySubCommand.java

@Override
public Options buildCommandlineOptions(Options options) {
    Option opt = new Option("i", "msgId", true, "Message Id");
    opt.setRequired(true);// w  w  w .  j  a  va  2  s .  c om
    options.addOption(opt);

    opt = new Option("g", "consumerGroup", true, "consumer group name");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("d", "clientId", true, "The consumer's client id");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("t", "topic", true, "The topic of msg");
    opt.setRequired(true);
    options.addOption(opt);

    return options;
}

From source file:it.drwolf.ridire.utility.CorpusPackager.java

private void createOptions() {
    this.options = new Options();
    Option f = new Option("f", "descfile", true, "description file");
    this.options.addOption(f);
    Option dir = new Option("d", "destDir", true, "destination dir");
    this.options.addOption(dir);
    Option min = new Option("m", "min", true, "min value");
    this.options.addOption(min);
    Option max = new Option("M", "max", true, "max value");
    this.options.addOption(max);
}

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

public void createOptions() {
    StringBuilder sb = new StringBuilder();

    for (RevocationReason reason : RevocationReason.INSTANCES) {
        if (sb.length() > 0) {
            sb.append(", ");
        }/*from   w w w.j a  va 2 s . com*/
        sb.append(reason);
        if (reason == RevocationReason.UNSPECIFIED) {
            sb.append(" (default)");
        }
    }

    Option option = new Option(null, "reason", true, "Revocation reason: " + sb);
    option.setArgName("reason");
    options.addOption(option);

    option = new Option(null, "comments", true, "Comments");
    option.setArgName("comments");
    options.addOption(option);

    options.addOption(null, "ca", false, "CA signing certificate");
    options.addOption(null, "force", false, "Force");
}

From source file:com.opengamma.integration.tool.portfolio.PortfolioInfoTool.java

protected Options createOptions(boolean contextProvided) {
    Options options = super.createOptions(contextProvided);

    Option origNameOption = new Option(PORTFOLIO_NAME, "origname", true,
            "The name of the OpenGamma portfolio to copy or rename");
    origNameOption.setRequired(true);/* www  .  ja va  2  s . c  om*/
    options.addOption(origNameOption);

    return options;
}

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

public static CommandLine buildCommandline(String[] args) {
    final Options options = new Options();
    Option opt = new Option("h", "help", false, "Print help");
    opt.setRequired(false);/*from w  ww .  j  av a  2  s . c  o m*/
    options.addOption(opt);

    opt = new Option("g", "consumerGroup", true, "Consumer 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("s", "subscription", true, "subscription");
    opt.setRequired(false);
    options.addOption(opt);

    opt = new Option("f", "returnFailedHalf", true, "return failed result, for half message");
    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.netscape.cmstools.ca.CACertFindCLI.java

public void createOptions() {
    Option option = null;//from ww w. j a  v a 2 s .  c  o  m

    //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);

    //file input
    option = new Option(null, "input", true, "File containing the search constraints");
    option.setArgName("file path");
    options.addOption(option);

    //serialNumberinUse
    option = new Option(null, "minSerialNumber", true, "Minimum serial number");
    option.setArgName("serial number");
    options.addOption(option);
    option = new Option(null, "maxSerialNumber", true, "Maximum serial number");
    option.setArgName("serial number");
    options.addOption(option);

    //subjectNameinUse
    option = new Option(null, "name", true, "Subject's common name");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "email", true, "Subject's email address");
    option.setArgName("email");
    options.addOption(option);
    option = new Option(null, "uid", true, "Subject's userid");
    option.setArgName("user id");
    options.addOption(option);
    option = new Option(null, "org", true, "Subject's organization");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "orgUnit", true, "Subject's organization unit");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "locality", true, "Subject's locality");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "state", true, "Subject's state");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "country", true, "Subject's country");
    option.setArgName("name");
    options.addOption(option);
    options.addOption(null, "matchExactly", false, "Match exactly with the details provided");

    //status
    option = new Option(null, "status", true,
            "Certificate status: VALID, INVALID, REVOKED, EXPIRED, REVOKED_EXPIRED");
    option.setArgName("status");
    options.addOption(option);

    //revokedByInUse
    option = new Option(null, "revokedBy", true, "Certificate revoked by");
    option.setArgName("user id");
    options.addOption(option);

    //revocationPeriod
    option = new Option(null, "revokedOnFrom", true, "Revoked on or after this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "revokedOnTo", true, "Revoked on or before this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //revocationReason
    option = new Option(null, "revocationReason", true,
            "Reason for revocation: Unspecified(0), Key_compromise(1), CA_Compromise(2), Affiliation_Changed(3), "
                    + "Superseded(4), Cessation_of_Operation(5), Certificate_Hold(6), Remove_from_CRL(8), "
                    + "Privilege_Withdrawn(9), AA_Compromise(10)");
    option.setArgName("reason");
    options.addOption(option);

    //issuedBy
    option = new Option(null, "issuedBy", true, "Issued by");
    option.setArgName("user id");
    options.addOption(option);

    //issuedOn
    option = new Option(null, "issuedOnFrom", true, "Issued on or after this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    option = new Option(null, "issuedOnTo", true, "Issued on or before this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //certTypeinUse
    option = new Option(null, "certTypeSubEmailCA", true, "Certifiate type: Subject Email CA");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSubSSLCA", true, "Certificate type: Subject SSL CA");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSecureEmail", true, "Certifiate Type: Secure Email");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSSLClient", true, "Certifiate Type: SSL Client");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSSLServer", true, "Certifiate Type: SSL Server");
    option.setArgName("on|off");
    options.addOption(option);

    //validationNotBeforeInUse
    option = new Option(null, "validNotBeforeFrom", true, "Valid not before start date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "validNotBeforeTo", true, "Valid not before end date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //validityNotAfterinUse
    option = new Option(null, "validNotAfterFrom", true, "Valid not after start date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "validNotAfterTo", true, "Valid not after end date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //validityLengthinUse
    option = new Option(null, "validityOperation", true, "Validity duration operation: \"<=\" or \">=\"");
    option.setArgName("operation");
    options.addOption(option);
    option = new Option(null, "validityCount", true, "Validity duration count");
    option.setArgName("count");
    options.addOption(option);
    option = new Option(null, "validityUnit", true, "Validity duration unit: day, week, month (default), year");
    option.setArgName("day|week|month|year");
    options.addOption(option);
}

From source file:com.github.dmyersturnbull.transformations.DataTransformationRunner.java

public void run(@Nonnull String... args) throws Exception {
    m_helper.addOptions(new Option("i", "input", true, "The input file"),
            new Option("o", "output", true, "The output file"));

    Optional<ExtendedCommandLine> response = m_helper.parse(args);
    if (response.isPresent()) {

        ExtendedCommandLine cli = response.get();

        Optional<File> input = cli.getFile("i");
        Optional<File> output = cli.getFile("o");

        if (input.isPresent() ^ output.isPresent()) {
            m_helper.printHelp();//  w w w.ja v  a 2  s. co  m
        } else if (!input.isPresent()) {
            m_constructor.construct(cli).pipe();
        } else {
            m_constructor.construct(cli).apply(input.get(), output.get());
        }
    }

}

From source file:com.yahoo.athenz.example.zts.tls.client.ZTSTLSClient.java

private static CommandLine parseCommandLine(String[] args) {

    Options options = new Options();

    Option domain = new Option("d", "domain", true, "domain name");
    domain.setRequired(true);//from w  ww.j  a va 2s.c  om
    options.addOption(domain);

    Option service = new Option("s", "service", true, "service name");
    service.setRequired(true);
    options.addOption(service);

    Option keyId = new Option("i", "keyid", true, "key id");
    keyId.setRequired(true);
    options.addOption(keyId);

    Option key = new Option("k", "key", true, "private key path");
    key.setRequired(true);
    options.addOption(key);

    Option cert = new Option("c", "cert", true, "certficate path");
    cert.setRequired(true);
    options.addOption(cert);

    Option trustStore = new Option("t", "trustStorePath", true, "CA TrustStore path");
    trustStore.setRequired(true);
    options.addOption(trustStore);

    Option trustStorePassword = new Option("p", "trustStorePassword", true, "CA TrustStore password");
    trustStorePassword.setRequired(true);
    options.addOption(trustStorePassword);

    Option ztsUrl = new Option("z", "ztsurl", true, "ZTS Server url");
    ztsUrl.setRequired(true);
    options.addOption(ztsUrl);

    Option proxyUrl = new Option("x", "proxy", true, "Proxy Server url");
    proxyUrl.setRequired(false);
    options.addOption(proxyUrl);

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

    try {
        cmd = parser.parse(options, args);
    } catch (ParseException e) {
        System.out.println(e.getMessage());
        formatter.printHelp("zts-tls-client", options);
        System.exit(1);
    }

    return cmd;
}

From source file:com.netscape.cmstools.cert.CertFindCLI.java

public void createOptions() {
    Option option = null;/*from w  w  w . j a v a2s.  co m*/

    //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);

    //file input
    option = new Option(null, "input", true, "File containing the search constraints");
    option.setArgName("file path");
    options.addOption(option);

    //serialNumberinUse
    option = new Option(null, "minSerialNumber", true, "Minimum serial number");
    option.setArgName("serial number");
    options.addOption(option);
    option = new Option(null, "maxSerialNumber", true, "Maximum serial number");
    option.setArgName("serial number");
    options.addOption(option);

    //subjectNameinUse
    option = new Option(null, "name", true, "Subject's common name");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "email", true, "Subject's email address");
    option.setArgName("email");
    options.addOption(option);
    option = new Option(null, "uid", true, "Subject's userid");
    option.setArgName("user id");
    options.addOption(option);
    option = new Option(null, "org", true, "Subject's organization");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "orgUnit", true, "Subject's organization unit");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "locality", true, "Subject's locality");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "state", true, "Subject's state");
    option.setArgName("name");
    options.addOption(option);
    option = new Option(null, "country", true, "Subject's country");
    option.setArgName("name");
    options.addOption(option);
    options.addOption(null, "matchExactly", false, "Match exactly with the details provided");

    //status
    option = new Option(null, "status", true,
            "Certificate status: VALID, INVALID, REVOKED, EXPIRED, REVOKED_EXPIRED");
    option.setArgName("status");
    options.addOption(option);

    //revokedByInUse
    option = new Option(null, "revokedBy", true, "Certificate revoked by");
    option.setArgName("user id");
    options.addOption(option);

    //revocationPeriod
    option = new Option(null, "revokedOnFrom", true, "Revoked on or after this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "revokedOnTo", true, "Revoked on or before this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //revocationReason
    option = new Option(null, "revocationReason", true, "Reason for revocation");
    option.setArgName("reason");
    options.addOption(option);

    //issuedBy
    option = new Option(null, "issuedBy", true, "Issued by");
    option.setArgName("user id");
    options.addOption(option);

    //issuedOn
    option = new Option(null, "issuedOnFrom", true, "Issued on or after this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    option = new Option(null, "issuedOnTo", true, "Issued on or before this date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //certTypeinUse
    option = new Option(null, "certTypeSubEmailCA", true, "Certifiate type: Subject Email CA");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSubSSLCA", true, "Certificate type: Subject SSL CA");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSecureEmail", true, "Certifiate Type: Secure Email");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSSLClient", true, "Certifiate Type: SSL Client");
    option.setArgName("on|off");
    options.addOption(option);
    option = new Option(null, "certTypeSSLServer", true, "Certifiate Type: SSL Server");
    option.setArgName("on|off");
    options.addOption(option);

    //validationNotBeforeInUse
    option = new Option(null, "validNotBeforeFrom", true, "Valid not before start date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "validNotBeforeTo", true, "Valid not before end date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //validityNotAfterinUse
    option = new Option(null, "validNotAfterFrom", true, "Valid not after start date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);
    option = new Option(null, "validNotAfterTo", true, "Valid not after end date");
    option.setArgName("YYYY-MM-DD");
    options.addOption(option);

    //validityLengthinUse
    option = new Option(null, "validityOperation", true, "Validity duration operation: \"<=\" or \">=\"");
    option.setArgName("operation");
    options.addOption(option);
    option = new Option(null, "validityCount", true, "Validity duration count");
    option.setArgName("count");
    options.addOption(option);
    option = new Option(null, "validityUnit", true, "Validity duration unit: day, week, month (default), year");
    option.setArgName("day|week|month|year");
    options.addOption(option);
}