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:com.google.enterprise.connector.persist.MigrateStore.java

@Override
public Options getOptions() {
    Options options = super.getOptions();
    options.addOption("l", "list", false, "List available PersistentStores.");
    options.addOption("f", "force", false, "Overwrite existing data in destination PersistentStore.");
    Option o = new Option("c", "connector_name", true, "Connector to migrate.");
    o.setArgName("connector_name");
    options.addOption(o);/*from w  w  w  . jav a2  s.  c  o m*/
    return options;
}

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

public void createOptions() {
    Option option = new Option(null, "cert", true, "PEM file to store the certificate.");
    option.setArgName("path");
    options.addOption(option);/*from w ww.j av a  2  s .c o  m*/

    option = new Option(null, "private-key", true, "PEM file to store the private key.");
    option.setArgName("path");
    options.addOption(option);

    option = new Option(null, "client-cert", true, "PEM file to store the certificate and the private key.");
    option.setArgName("path");
    options.addOption(option);

    option = new Option(null, "pkcs12", true,
            "PKCS #12 file to store the certificate chain and the private key.");
    option.setArgName("path");
    options.addOption(option);

    option = new Option(null, "pkcs12-password", true, "PKCS #12 file password.");
    option.setArgName("password");
    options.addOption(option);
}

From source file:com.soulgalore.crawler.run.AbstractCrawl.java

/**
 * Get hold of the default options.//from  w ww  . j  a  va2  s .  c o m
 * 
 * @return the options that needs to run a crawl
 */
@Override
protected Options getOptions() {
    final Options options = super.getOptions();

    final Option urlOption = new Option("u",
            "the page that is the startpoint of the crawl, examle http://mydomain.com/mypage");
    urlOption.setLongOpt(URL);
    urlOption.setArgName("URL");
    urlOption.setRequired(true);
    urlOption.setArgs(1);

    options.addOption(urlOption);

    final Option levelOption = new Option("l", "how deep the crawl should be done, default is "
            + CrawlerConfiguration.DEFAULT_CRAWL_LEVEL + " [optional]");
    levelOption.setArgName("LEVEL");
    levelOption.setLongOpt(LEVEL);
    levelOption.setRequired(false);
    levelOption.setArgs(1);
    options.addOption(levelOption);

    final Option followOption = new Option("p", "stay on this path when crawling [optional]");
    followOption.setArgName("PATH");
    followOption.setLongOpt(FOLLOW_PATH);
    followOption.setRequired(false);
    followOption.setArgs(1);
    options.addOption(followOption);

    final Option noFollowOption = new Option("np", "no url:s on this path will be crawled [optional]");
    noFollowOption.setArgName("NOPATH");
    noFollowOption.setLongOpt(NO_FOLLOW_PATH);
    noFollowOption.setRequired(false);
    noFollowOption.setArgs(1);
    options.addOption(noFollowOption);

    final Option verifyOption = new Option("v", "verify that all links are returning 200, default is set to "
            + CrawlerConfiguration.DEFAULT_SHOULD_VERIFY_URLS + " [optional]");
    verifyOption.setArgName("VERIFY");
    verifyOption.setLongOpt(VERIFY);
    verifyOption.setRequired(false);
    verifyOption.setArgs(1);
    options.addOption(verifyOption);

    final Option requestHeadersOption = new Option("rh",
            "the request headers by the form of header1:value1@header2:value2 [optional]");
    requestHeadersOption.setArgName("REQUEST-HEADERS");
    requestHeadersOption.setLongOpt(REQUEST_HEADERS);
    requestHeadersOption.setRequired(false);
    requestHeadersOption.setArgs(1);
    options.addOption(requestHeadersOption);

    return options;
}

From source file:de.hsos.ecs.richwps.wpsmonitor.boundary.cli.command.annotation.CommandAnnotationProcessor.java

private void addOptions(final Command cmd) throws CommandAnnotationProcessorException {
    final List<Field> fields = getFields(cmd.getClass());

    for (final Field field : fields) {
        final CommandOption annotation = field.getAnnotation(CommandOption.class);

        if (annotation != null) {
            final String longOpt = annotation.longOptionName().equals("") ? null : annotation.longOptionName();

            Option option = new Option(annotation.shortOptionName(), longOpt, annotation.hasArgument(),
                    annotation.description());

            if (annotation.hasArgument()) {
                option.setArgName(annotation.argumentName());
            } else {
                if (!field.getType().equals(Boolean.class)) {
                    throw new CommandAnnotationProcessorException(
                            "If the Option has no argument, the field must be of type boolean.");
                }// w ww .java 2 s . c o m
            }

            option.setOptionalArg(annotation.optionalArgument());

            cmd.addOption(option);
        }
    }
}

From source file:is.hi.bok.deduplicator.CommandLineParser.java

/**
 * Constructor./*from   ww w.java 2  s. c o  m*/
 *
 * @param args Command-line arguments to process.
 * @param out PrintStream to write on.
 * @throws ParseException Failed parse of command line.
 */
public CommandLineParser(String[] args, PrintWriter out) throws ParseException {
    super();

    this.out = out;

    this.options = new Options();
    this.options.addOption(new Option("h", "help", false, "Prints this message and exits."));

    Option opt = new Option("o", "mode", true, "Index by URL, HASH or BOTH. Default: BOTH.");
    opt.setArgName("type");
    this.options.addOption(opt);

    this.options.addOption(new Option("s", "equivalent", false,
            "Include a stripped URL in the index for equivalent URL " + "matches."));

    this.options.addOption(new Option("t", "timestamp", false, "Include the time of fetch in the index."));

    this.options.addOption(
            new Option("e", "etag", false, "Include etags in the index (if available in the source)."));

    opt = new Option("m", "mime", true,
            "A filter on what mime types are added into the index " + "(blacklist). Default: ^text/.*");
    opt.setArgName("reg.expr.");
    this.options.addOption(opt);

    this.options.addOption(
            new Option("w", "whitelist", false, "Make the --mime filter a whitelist instead of blacklist."));

    opt = new Option("i", "iterator", true,
            "An iterator suitable for the source data (default iterator " + "works on Heritrix's crawl.log).");
    opt.setArgName("classname");
    this.options.addOption(opt);

    this.options.addOption(new Option("a", "add", false, "Add source data to existing index."));

    opt = new Option("r", "origin", true,
            "If set, the 'origin' of each URI will be added to the index."
                    + " If no origin is provided by the source data then the "
                    + "argument provided here will be used.");
    opt.setArgName("origin");
    this.options.addOption(opt);

    this.options.addOption(new Option("d", "skip-duplicates", false,
            "If set, URIs marked as duplicates will not be added to the " + "index."));

    PosixParser parser = new PosixParser();
    try {
        this.commandLine = parser.parse(this.options, args, false);
    } catch (UnrecognizedOptionException e) {
        usage(e.getMessage(), 1);
    }
}

From source file:edu.vt.middleware.crypt.signature.SignatureCli.java

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

    final Option alg = new Option(OPT_ALG, true, "signature algorithm; either DSA or RSA");
    alg.setArgName("name");
    alg.setOptionalArg(false);/*  w w w  . j  av  a  2  s  . c  o m*/

    final Option key = new Option(OPT_KEY, true,
            "DER-encoded PKCS#8 private key for signing or " + "X.509 cert/public key for verification");
    key.setArgName("filepath");
    key.setOptionalArg(false);

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

    final Option digest = new Option(OPT_DIGEST, true,
            "message digest algorithm used to produce encoded message to sign");
    digest.setArgName("algname");
    digest.setOptionalArg(false);

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

    final Option verify = new Option(OPT_VERIFY, true,
            "verify signature in given file; " + "signature encoding determined by -encoding option");
    encoding.setArgName("sigfilepath");
    encoding.setOptionalArg(false);

    options.addOption(alg);
    options.addOption(key);
    options.addOption(infile);
    options.addOption(digest);
    options.addOption(encoding);
    options.addOption(verify);
    options.addOption(new Option(OPT_SIGN, "perform sign operation"));
}

From source file:kieker.tools.resourceMonitor.ResourceMonitor.java

@Override
protected void addAdditionalOptions(final Options options) {
    final Option intervalOption = new Option(null, "interval", true, "Sampling interval");
    intervalOption.setArgName("interval");
    intervalOption.setRequired(false);// ww w.  ja  v a 2s  .c  o m
    intervalOption.setArgs(1);
    options.addOption(intervalOption);

    final Option intervalUnitOption = new Option(null, "interval-unit", true,
            "Sampling interval time unit (default: SECONDS)");
    intervalUnitOption.setArgName("interval-unit");
    intervalUnitOption.setRequired(false);
    intervalUnitOption.setArgs(1);
    options.addOption(intervalUnitOption);

    final Option initialDelayOption = new Option(null, "initial-delay", true, "Initial delay");
    initialDelayOption.setArgName("initial-delay");
    initialDelayOption.setRequired(false);
    initialDelayOption.setArgs(1);
    options.addOption(initialDelayOption);

    final Option durationUnitOption = new Option(null, "initial-delay-unit", true,
            "Initial delay time unit (default: SECONDS)");
    durationUnitOption.setArgName("initial-delay-unit");
    durationUnitOption.setRequired(false);
    durationUnitOption.setArgs(1);
    options.addOption(durationUnitOption);

    final Option initialDelayUnitOption = new Option(null, "duration", true, "Monitoring duration");
    initialDelayUnitOption.setArgName("duration");
    initialDelayUnitOption.setRequired(false);
    initialDelayUnitOption.setArgs(1);
    options.addOption(initialDelayUnitOption);

    final Option durationOption = new Option(null, "duration-unit", true,
            "Monitoring duration time unit (default: MINUTES)");
    durationOption.setArgName("duration-unit");
    durationOption.setRequired(false);
    durationOption.setArgs(1);
    options.addOption(durationOption);

    final Option configurationFileOption = new Option("c", CMD_OPT_NAME_MONITORING_CONFIGURATION, true,
            "Configuration to use for the Kieker monitoring instance");
    configurationFileOption.setArgName(OPTION_EXAMPLE_FILE_MONITORING_PROPERTIES);
    configurationFileOption.setRequired(false);
    configurationFileOption.setValueSeparator('=');
    options.addOption(configurationFileOption);
}

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  . j ava2 s.c o m

    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.opengamma.integration.marketdata.manipulator.dsl.SimulationTool.java

@Override
protected Options createOptions(boolean mandatoryConfigResource) {
    Options options = super.createOptions(mandatoryConfigResource);

    Option viewDefNameOption = new Option(VIEW_DEF_NAME_OPTION, true, "View definition name");
    viewDefNameOption.setRequired(true);
    viewDefNameOption.setArgName("viewdefname");
    options.addOption(viewDefNameOption);

    Option marketDataOption = new Option(MARKET_DATA_OPTION, true, "Market data source names");
    marketDataOption.setRequired(true);/*w  ww .ja v  a  2 s. c  o  m*/
    marketDataOption.setArgName("marketdata");
    options.addOption(marketDataOption);

    Option simulationScriptOption = new Option(SIMULATION_SCRIPT_OPTION, true, "Simulation script location");
    simulationScriptOption.setRequired(true);
    simulationScriptOption.setArgName("simulationscript");
    options.addOption(simulationScriptOption);

    Option paramScriptOption = new Option(PARAMETER_SCRIPT_OPTION, true,
            "Simulation parameters script location");
    paramScriptOption.setArgName("simulationparameters");
    options.addOption(paramScriptOption);

    Option batchModeOption = new Option(BATCH_MODE_OPTION, false, "Run in batch mode");
    batchModeOption.setArgName("batchmode");
    options.addOption(batchModeOption);

    Option resultListenerClassOption = new Option(RESULT_LISTENER_CLASS_OPTION, true,
            "Result listener class " + "implementing ViewResultListener");
    resultListenerClassOption.setArgName("resultlistenerclass");
    options.addOption(resultListenerClassOption);

    return options;
}

From source file:edu.ksu.cis.indus.tools.slicer.SliceXMLizerCLI.java

/**
 * Parses the command line argument./*www. j a  va2 s .c  o m*/
 * 
 * @param args contains the command line arguments.
 * @param xmlizer used to xmlize the slice.
 * @pre args != null and xmlizer != null
 */
private static void parseCommandLine(final String[] args, final SliceXMLizerCLI xmlizer) {
    // create options
    final Options _options = new Options();
    Option _o = new Option("c", "config-file", true,
            "The configuration file to use.  If unspecified, uses default configuration file.");
    _o.setArgs(1);
    _o.setArgName("config-file");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("a", "active-config", true,
            "The alternate configuration to use instead of the one specified in the configuration.");
    _o.setArgs(1);
    _o.setArgName("config");
    _o.setLongOpt("active-config");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("o", "output-dir", true,
            "The output directory to dump the generated info.  If unspecified, picks a temporary directory.");
    _o.setArgs(1);
    _o.setArgName("path");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("g", "gui-config", false, "Display gui for configuration.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("p", "soot-classpath", true, "Prepend this to soot class path.");
    _o.setArgs(1);
    _o.setArgName("classpath");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("e", "exception-preserving-slice", true,
            "Generate slice that preserves every throw statement in "
                    + "the application class. Comma-separated combination of optional arguments: inAppOnly - preserve throw "
                    + "statements in application classes only, separateSlices - generated a different slice for each throw "
                    + "statement. **This option should not be combined with -r**");
    _o.setArgs(1);
    _o.setOptionalArg(true);
    _o.setArgName("applClassOnly");
    _options.addOption(_o);
    _o = new Option(" ", "detailedStats", false, "Display detailed stats.");
    _o.setOptionalArg(false);
    _o = new Option("h", "help", false, "Display message.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("i", "output-xml-jimple-before-res", false,
            "Output xml representation of the jimple BEFORE residualization.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("j", "output-xml-jimple-after-res", false,
            "Output xml representation of the jimple AFTER residualization. This only works with -r option.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("I", "output-jimple-before-res", false, "Output jimple BEFORE residualization.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("J", "output-jimple-after-res", false,
            "Output jimple AFTER residualization. This only works with -r option.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("s", "criteria-spec-file", true, "Use the slice criteria specified in this file.");
    _o.setArgs(1);
    _o.setArgName("crit-spec-file");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("sa", "Perform scoped analysis (as opposed merely performing scoped slicing)");
    _options.addOption(_o);
    _o = new Option("S", "slice-scope-spec-file", true, "Use the scope specified in this file.");
    _o.setArgs(1);
    _o.setArgName("slice-scope-spec-file");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("r", "residualize", true,
            "Residualize after slicing. This will also dump the class files for the residualized classes.  Provide the "
                    + "name of the file as an optional argument to optimize the slice (via transformation) for space.  The file should"
                    + "contain the FQN of classes (1 per line) to be retained during optimization.");
    _o.setOptionalArg(true);
    _options.addOption(_o);
    _o = new Option("x", "output-slice-xml", false, "Output xml representation of the slice.");
    _o.setOptionalArg(false);
    _options.addOption(_o);
    _o = new Option("l", true, "Generate criteria based on line number based criteria spec file. The format is "
            + "<class FQN>=<comma-separated list of line numbers from the class containing  Java file>.");
    _o.setArgs(1);
    _o.setArgName("line-based-criteria-spec-file");
    _o.setOptionalArg(false);
    _options.addOption(_o);

    CommandLine _cl = null;

    // parse the arguments
    Exception _exception = null;

    try {
        _cl = (new BasicParser()).parse(_options, args);
    } catch (ParseException _e) {
        _exception = _e;
    }

    if (_exception != null || _cl.hasOption("h")) {
        printUsage(_options);

        if (_exception != null) {
            LOGGER.error("Incorrect command line.  Aborting.", _exception);
            System.exit(1);
        } else {
            System.exit(0);
        }
    }
    xmlizer.setConfiguration(processCommandLineForConfiguration(_cl));
    setupOutputOptions(_cl, xmlizer);

    if (_cl.hasOption('p')) {
        xmlizer.addToSootClassPath(_cl.getOptionValue('p'));
    }

    if (_cl.hasOption('a')) {
        xmlizer.setConfigName(_cl.getOptionValue('a'));
    }

    if (_cl.hasOption('g')) {
        xmlizer.showGUI();
    }

    if (_cl.hasOption('s')) {
        xmlizer.setSliceCriteriaSpecFile(_cl.getOptionValue('s'));
    }

    if (_cl.hasOption('r')) {
        xmlizer.setResidulization(true);

        final String _optionValue = _cl.getOptionValue('r');

        if (_optionValue != null) {
            xmlizer.extractExclusionListForCompaction(_optionValue);
        }
    }

    if (_cl.hasOption('S')) {
        sliceScope = xmlizer.setScopeSpecFile(_cl.getOptionValue('S'));
        if (_cl.hasOption("sa")) {
            xmlizer.setScopeSpecFile(_cl.getOptionValue('S'));
        } else {
            xmlizer.setScopeSpecFile(null);
        }
    }

    if (_cl.hasOption('l')) {
        xmlizer.setLineBasedCriteriaSpecFile(_cl.getOptionValue('l'));
    }

    xmlizer.preserveThrowStatements = _cl.hasOption('e');
    if (xmlizer.preserveThrowStatements) {
        xmlizer.parseThrowStmtTreatmentOptions(_cl.getOptionValue('e'));
    }

    if (xmlizer.generateSeparateSlicesForEachThrowStmt && xmlizer.residualize) {
        throw new IllegalArgumentException(
                "Residualization (-r) cannot be combined multiple slice generation mode (-e separateSlices).");
    }

    xmlizer.detailedStats = _cl.hasOption("detailedStats");

    xmlizer.shouldWriteSliceXML = _cl.hasOption('x');

    final List<String> _result = _cl.getArgList();

    if (_result.isEmpty()) {
        LOGGER.error(
                "Please specify atleast one class that contains an entry method into the system to be sliced.");
        System.exit(1);
    }

    xmlizer.setClassNames(_result);
}