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:kieker.tools.KaxViz.java

@Override
protected void addAdditionalOptions(final Options options) {
    final Option inputOption = new Option("i", "input", true, "the analysis project file (.kax) loaded");
    final Option outputoption = new Option("svg", true, "name of svg saved on close");

    inputOption.setArgName("filename");
    outputoption.setArgName("filename");

    options.addOption(inputOption);//  ww w  .ja va2s  . com
    options.addOption(outputoption);
}

From source file:com.netscape.cmstools.client.ClientCertRequestCLI.java

public void createOptions() {
    Option option = new Option(null, "type", true, "Request type (default: pkcs10)");
    option.setArgName("request type");
    options.addOption(option);//w w w .  j a v a  2  s. co  m

    option = new Option(null, "username", true, "Username for request authentication");
    option.setArgName("username");
    options.addOption(option);

    option = new Option(null, "password", false, "Prompt password for request authentication");
    options.addOption(option);

    option = new Option(null, "attribute-encoding", false, "Enable Attribute encoding");
    options.addOption(option);

    option = new Option(null, "algorithm", true, "Algorithm (default: rsa)");
    option.setArgName("algorithm name");
    options.addOption(option);

    option = new Option(null, "length", true, "RSA key length (default: 1024)");
    option.setArgName("key length");
    options.addOption(option);

    option = new Option(null, "curve", true, "ECC key curve name (default: nistp256)");
    option.setArgName("curve name");
    options.addOption(option);

    option = new Option(null, "ssl-ecdh", false, "SSL certificate with ECDH ECDSA");
    options.addOption(option);

    option = new Option(null, "permanent", false, "Permanent");
    options.addOption(option);

    option = new Option(null, "sensitive", true, "Sensitive");
    option.setArgName("boolean");
    options.addOption(option);

    option = new Option(null, "extractable", true, "Extractable");
    option.setArgName("boolean");
    options.addOption(option);

    option = new Option(null, "transport", true, "PEM transport certificate");
    option.setArgName("path");
    options.addOption(option);

    option = new Option(null, "profile", true,
            "Certificate profile (RSA default: caUserCert, ECC default: caECUserCert)");
    option.setArgName("profile");
    options.addOption(option);

    option = new Option(null, "without-pop", false, "Do not include Proof-of-Possession in CRMF request");
    options.addOption(option);

    option = new Option(null, "issuer-id", true, "Authority ID (host authority if omitted)");
    option.setArgName("ID");
    options.addOption(option);

    option = new Option(null, "issuer-dn", true, "Authority DN (host authority if omitted)");
    option.setArgName("DN");
    options.addOption(option);

    options.addOption(null, "help", false, "Show help message.");
}

From source file:info.mikaelsvensson.devtools.analysis.shared.CommandLineUtil.java

public List<Option> getOptions(Object owner) throws IllegalAccessException {
    List<Option> options = new ArrayList<Option>();
    Class<?> cls = owner.getClass();
    do {//www.j  a  v a2  s  .co  m
        CliOptions cliOptions = cls.getAnnotation(CliOptions.class);
        if (cliOptions != null) {
            for (CliOptionConfig config : cliOptions.opts()) {

                if (config != null) {
                    Option option = new Option(config.name(), config.description());
                    if (config.longName().length() > 0) {
                        option.setLongOpt(config.longName());
                    }
                    if (config.numArgs() == OPTIONAL) {
                        option.setOptionalArg(true);
                    } else {
                        option.setArgs(config.numArgs());
                    }
                    option.setArgName(config.argsDescription());
                    option.setRequired(config.required());
                    option.setValueSeparator(config.separator());
                    options.add(option);
                }
            }
        }
    } while ((cls = cls.getSuperclass()) != null);
    return options;
}

From source file:de.uni_koblenz.jgralab.utilities.tg2whatever.Tg2Whatever.java

final protected OptionHandler createOptionHandler() {
    String toolString = "java " + this.getClass().getName();
    String versionString = JGraLab.getInfo(false);
    OptionHandler oh = new OptionHandler(toolString, versionString);

    Option graph = new Option("g", "graph", true, "(required): the graph to be converted");
    graph.setRequired(true);/*from  w  w w  .j a  v  a  2  s  .c  o m*/
    graph.setArgName("file");
    oh.addOption(graph);

    Option alternativeSchema = new Option("a", "alternative-schema", true,
            "(optional): the schema that should be used instead of the one included in the graph file");
    alternativeSchema.setRequired(false);
    graph.setArgName("file");
    oh.addOption(alternativeSchema);

    Option domains = new Option("d", "domains", false,
            "(optional): if set, domain names of attributes will be printed");
    domains.setRequired(false);
    oh.addOption(domains);

    Option edgeAttributes = new Option("e", "edgeattr", false,
            "(optional): if set, edge attributes will be printed");
    edgeAttributes.setRequired(false);
    oh.addOption(edgeAttributes);

    Option rolenames = new Option("n", "rolenames", false, "(optional): if set, role names will be printed");
    rolenames.setRequired(false);
    oh.addOption(rolenames);

    Option output = new Option("o", "output", true, "(required): the output file name, or empty for stdout");
    output.setRequired(true);
    output.setArgName("file");
    oh.addOption(output);

    Option reversed = new Option("r", "reversed", false,
            "(optional): useful if edges run from child nodes to their parents results in a tree with root node at top");
    reversed.setRequired(false);
    oh.addOption(reversed);

    Option shortenStrings = new Option("s", "shorten-strings", false,
            "(optional): if set, strings are shortened");
    shortenStrings.setRequired(false);
    oh.addOption(shortenStrings);
    return oh;
}

From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java

/**
 * Processes all command line parameters and returns a {@link CommandLine}
 * object, which holds all values included in the given {@link String}
 * array./* w w w.ja  v a 2  s.c  om*/
 * 
 * @param args
 *            {@link CommandLine} parameters.
 * @return {@link CommandLine} object, which holds all necessary values.
 */
public static CommandLine processCommandLineOptions(String[] args) {

    // Creates a OptionHandler.
    String toolString = "java " + SchemaGraph2XMI.class.getName();
    String versionString = JGraLab.getInfo(false);

    OptionHandler oh = new OptionHandler(toolString, versionString);

    // Several Options are declared.
    Option output = new Option("o", "output", true, "(required): the output xmi file name");
    output.setRequired(true);
    output.setArgName("file");
    oh.addOption(output);

    Option schemaGraph = new Option("ig", "inputSchemaGraph", true,
            "(required or -i):if set, the schemaGraph is converted into a xmi.");
    schemaGraph.setRequired(false);
    schemaGraph.setArgs(0);
    output.setArgName("file");
    oh.addOption(schemaGraph);

    Option schema = new Option("i", "inputSchema", true,
            "(required or -ig): TG-file of the schema which should be converted into a xmi.");
    schema.setRequired(false);
    schema.setArgName("file");
    oh.addOption(schema);

    // either graph or schema has to be provided
    OptionGroup input = new OptionGroup();
    input.addOption(schemaGraph);
    input.addOption(schema);
    input.setRequired(true);
    oh.addOptionGroup(input);

    Option bidirectional = new Option("b", "bidirectional", false,
            "(optional): If set the EdgeClasses are created as bidirectional associations.");
    bidirectional.setRequired(false);
    oh.addOption(bidirectional);

    return oh.parse(args);
}

From source file:com.buildml.main.BMLAdminMain.java

/**
 * Process the global command line arguments, using the Apache Commons CLI library.
 * Global options are defined as being those arguments that appear before the sub-command
 * name. They are distinct from "command options" that are specific to each sub-command.
 * /* w w  w  .j ava  2  s  . c  o  m*/
 * @param args The standard command line array from the main() method.
 * @return The remaining command line arguments (with global options excluded), with the first
 * being the command name.
 */
private String[] processGlobalOptions(String[] args) {

    /* create a new Apache Commons CLI parser, using Posix style arguments */
    CommandLineParser parser = new PosixParser();

    /* define the bml command's arguments */
    globalOpts = new Options();

    /* add the -f / --file option */
    Option fOpt = new Option("f", "file", true, "Name of build database to query/edit");
    fOpt.setArgName("file-name");
    globalOpts.addOption(fOpt);

    /* add the -h / --help option */
    Option hOpt = new Option("h", "help", false, "Show this help information");
    globalOpts.addOption(hOpt);

    /* add the -v / --version option */
    Option vOpt = new Option("v", "version", false, "Show version information");
    globalOpts.addOption(vOpt);

    /* how many columns of output should we show (default is 80) */
    Option widthOpt = new Option("w", "width", true,
            "Number of output columns in reports (default is " + CliUtils.getColumnWidth() + ")");
    globalOpts.addOption(widthOpt);

    /*
     * Initiate the parsing process - also, report on any options that require
     * an argument but didn't receive one. We only want to parse arguments
     * up until the first non-argument (that doesn't start with -).
     */
    CommandLine line = null;
    try {
        line = parser.parse(globalOpts, args, true);

    } catch (ParseException e) {
        displayHelpAndExit(e.getMessage());
    }

    /*
     * Validate all the options and their argument values.
     */
    if (line.hasOption('f')) {
        buildStoreFileName = line.getOptionValue('f');
    }

    if (line.hasOption('h')) {
        optionHelp = true;
    }

    if (line.hasOption('v')) {
        optionVersion = true;
    }

    String argWidth = line.getOptionValue("width");
    if (argWidth != null) {
        try {
            int newWidth = Integer.valueOf(argWidth);
            CliUtils.setColumnWidth(newWidth);
        } catch (NumberFormatException ex) {
            CliUtils.reportErrorAndExit("Invalid argument to --width: " + argWidth);
        }
    }

    /* 
     * Return the array of arguments that come after the global option. This
     * includes the sub-command name, any sub-command options, and the sub-command's
     * arguments.
     */
    return line.getArgs();
}

From source file:com.zimbra.common.soap.SoapTestHarness.java

public void runTests(String args[]) throws HarnessException, IOException, ServiceException {

    CliUtil.toolSetup();//  w w w  .  j a v  a 2s  .  co m
    SoapTransport.setDefaultUserAgent("SoapTestHarness", null);

    CommandLineParser parser = new GnuParser();
    Options options = new Options();

    options.addOption("h", "help", false, "print usage");
    options.addOption("d", "debug", false, "debug");
    options.addOption("s", "expandsystemprops", false, "exoand system properties");

    Option fileOpt = new Option("f", "file", true, "input document");
    fileOpt.setArgName("request-document");
    fileOpt.setRequired(true);
    options.addOption(fileOpt);

    CommandLine cl = null;
    boolean err = false;
    try {
        cl = parser.parse(options, args);
    } catch (ParseException pe) {
        System.err.println("error: " + pe.getMessage());
        err = true;
    }

    if (err || cl.hasOption("help"))
        usage(options);

    mDebug = cl.hasOption("d");
    String file = cl.getOptionValue("f");

    if (cl.hasOption("s"))
        expandSystemProperties();
    ;

    String docStr = new String(ByteUtil.getContent(new File(file)), "utf-8");
    doTests(Element.parseXML(docStr));

    //Element request = doc.getRootElement();
    //Element response = trans.invoke(request, isRaw);
    //System.out.println(DomUtil.toString(response, true));

    if (mTransport != null)
        mTransport.shutdown();
}

From source file:jp.ne.sakura.kkkon.StripElfSectionHeader.AppOption.java

public void createOptions() {
    Options opts = new Options();

    {/*  w  ww.j a v  a  2s  .  c o  m*/
        Option o = new Option("B", "batch", false, "batch mode. non interactive.");
        opts.addOption(o);
    }
    {
        Option o = new Option(null, "dry-run", false, "dry run");
        opts.addOption(o);
    }
    {
        Option o = new Option(null, "no-keep", false, "no keep backup");
        opts.addOption(o);
    }
    {
        Option o = new Option("o", "output", true, "output file or directory");
        o.setArgName("dest");
        opts.addOption(o);
    }
    opts.addOption("r", "recursive", false, "recursive directory");
    opts.addOption("v", "verbose", false, "verbose display");

    this.options = opts;
}

From source file:net.kyllercg.acms.ACMgen.java

/**
 * Creates the valid command line options
 *///from  w ww.  java  2  s . c o  m
private void createOptions() {

    Option op_help = new Option("h", "help", false, ACMgen.msg.getMessage("help_desc"));

    Option op_rrbb = new Option("r", "rrbb", true, ACMgen.msg.getMessage("rrbb_desc"));
    op_rrbb.setArgs(1);
    op_rrbb.setArgName("size");
    Option op_owbb = new Option("o", "owbb", true, ACMgen.msg.getMessage("owbb_desc"));
    op_owbb.setArgs(1);
    op_owbb.setArgName("size");
    Option op_owrrbb = new Option("b", "owrrbb", true, ACMgen.msg.getMessage("owrrbb_desc"));
    op_owrrbb.setArgs(1);
    op_owrrbb.setArgName("size");

    Option op_cpp = new Option("C", "cpp", false, ACMgen.msg.getMessage("cpp_desc"));
    Option op_verilog = new Option("v", "verilog", false, ACMgen.msg.getMessage("verilog_desc"));
    Option op_pep = new Option("p", "pep", false, ACMgen.msg.getMessage("pep_desc"));
    Option op_petrify = new Option("P", "petrify", false, ACMgen.msg.getMessage("petrify_desc"));
    Option op_smv = new Option("s", "smv", false, ACMgen.msg.getMessage("smv_desc"));
    Option op_smv_pn = new Option("S", "smvpn", false, ACMgen.msg.getMessage("smvpn_desc"));

    OptionGroup op_acm_group = new OptionGroup();
    op_acm_group.setRequired(true);
    op_acm_group.addOption(op_help);
    op_acm_group.addOption(op_rrbb);
    op_acm_group.addOption(op_owbb);
    op_acm_group.addOption(op_owrrbb);

    this.options = new Options();
    this.options.addOptionGroup(op_acm_group);
    this.options.addOption(op_cpp);
    this.options.addOption(op_verilog);
    this.options.addOption(op_pep);
    this.options.addOption(op_petrify);
    this.options.addOption(op_smv);
    this.options.addOption(op_smv_pn);
}

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

public void createOptions() {
    Option option = null;

    //pagination options
    option = new Option(null, "start", true, "Page start");
    option.setArgName("start");
    options.addOption(option);//from w w  w  .  j ava  2  s .  co  m

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