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

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

Introduction

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

Prototype

public void setArgs(int num) 

Source Link

Document

Sets the number of argument values this Option can take.

Usage

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

/**
 * Get the options.//w  w  w .  j  av  a2s  . c o m
 * 
 * @return the specific CrawlToCsv options
 */
@Override
protected Options getOptions() {
    final Options options = super.getOptions();

    final Option filenameOption = new Option("k", "the keyword to search for in the page  [required]");
    filenameOption.setArgName("KEYWORD");
    filenameOption.setLongOpt("keyword");
    filenameOption.setRequired(true);
    filenameOption.setArgs(1);

    options.addOption(filenameOption);

    return options;

}

From source file:com.zimbra.cs.mailbox.calendar.FixCalendarTZUtil.java

@Override
protected void setupCommandLineOptions() {
    super.setupCommandLineOptions();
    Options options = getOptions();/* ww  w  . ja va  2  s.  co  m*/
    Option rulefileOpt = new Option(null, O_RULEFILE, true, "xml file containing fixup rules");
    rulefileOpt.setRequired(true);
    options.addOption(rulefileOpt);
    Option accountOpt = new Option(O_ACCOUNT, "account", true,
            "account email addresses seperated by white space or \"all\" for all accounts");
    accountOpt.setRequired(true);
    accountOpt.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(accountOpt);
    options.addOption(new Option(null, O_AFTER, true,
            "fixup calendar items after this time; defaults to beginning of 2007"));
    options.addOption(new Option(null, O_SYNC, false, "run synchronously; default is asynchronous"));
    options.addOption(SoapCLI.OPT_AUTHTOKEN);
    options.addOption(SoapCLI.OPT_AUTHTOKENFILE);
}

From source file:fr.inrialpes.exmo.align.cli.CommonCLI.java

protected Option createListOption(String name, String longName, String desc, String argName, char sep) {
    Option opt = createOption(name, longName, desc);
    opt.setArgName(argName);/*from   www .  j a v  a2s .  c  o m*/
    opt.setValueSeparator(sep);
    opt.setRequired(true);
    opt.setArgs(-2); // Nicely undocumented!
    return opt;
}

From source file:net.orpiske.ssps.sdm.actions.Installer.java

@Override
protected void processCommand(String[] args) {
    CommandLineParser parser = new PosixParser();

    options = new Options();

    options.addOption("h", "help", false, "prints the help");
    options.addOption("g", "groupid", true, "package group id");
    options.addOption("p", "package", true, "package name");
    options.addOption("r", "repository", true, "the name of the repository to use");
    options.addOption(null, "cleanup", false, "cleanup the work directory after finished");
    options.addOption(null, "reinstall", false, "reinstall already installed packages");
    options.addOption(null, "view", false, "only view the packages to be installed");

    Option phasesOptions = OptionBuilder.withLongOpt("phases").create();
    phasesOptions.setArgs(6);
    phasesOptions.setRequired(false);//from w  ww.j  a v  a2 s  .c  o m
    phasesOptions.setDescription("the install phase(s) to run (implies --nodeps)");

    options.addOption(phasesOptions);

    options.addOption(null, "nodeps", false, "does not install dependencies");
    options.addOption("v", "version", true, "version");

    try {
        cmdLine = parser.parse(options, args);
    } catch (ParseException e) {
        help(options, -1);
    }

    isHelp = cmdLine.hasOption("help");
    reinstall = cmdLine.hasOption("reinstall");
    cleanup = cmdLine.hasOption("cleanup");
    view = cmdLine.hasOption("view");

    packageName = cmdLine.getOptionValue('p');
    if (packageName == null) {
        help(options, -1);
    }

    groupId = cmdLine.getOptionValue('g');
    version = cmdLine.getOptionValue('v');
    phases = cmdLine.getOptionValues("phases");

    if (phases != null && phases.length > 0) {
        nodeps = true;
    } else {
        nodeps = cmdLine.hasOption("nodeps");
    }

    repository = cmdLine.getOptionValue('r');
}

From source file:lu.uni.adtool.tools.Clo.java

public Clo() {
    this.options = new org.apache.commons.cli.Options();
    this.options.addOption("h", "help", false, Options.getMsg("clo.help.txt"));
    this.options.addOption("v", "version", false, Options.getMsg("clo.version.txt"));
    //     this.options.addOption("a", "all-domains", false, Options.getMsg("clo.allDomains.txt"));
    this.options.addOption("D", "no-derived", false, Options.getMsg("clo.derived.txt"));
    this.options.addOption("m", "mark-editable", false, Options.getMsg("clo.markEditable.txt"));
    this.options.addOption("L", "no-labels", false, Options.getMsg("clo.labels.txt"));
    this.options.addOption("C", "no-computed", false, Options.getMsg("clo.computed.txt"));
    // this.options.addOption("r", "rank", false,
    // Options.getMsg("clo.rank.txt"));

    Option option = new Option("o", "open", true, Options.getMsg("clo.open.txt"));
    // Set option c to take 1 to oo arguments
    option.setArgs(Option.UNLIMITED_VALUES);
    option.setArgName("file_1>...<file_N");
    this.options.addOption(option);
    option = new Option("i", "import", true, Options.getMsg("clo.import.txt"));
    option.setArgName("file");
    this.options.addOption(option);
    option = new Option("x", "export", true, Options.getMsg("clo.export.txt"));
    option.setArgName("file");
    this.options.addOption(option);
    option = new Option("d", "domain", true, Options.getMsg("clo.domain.txt"));
    //     option.setValueSeparator(',');
    //     option.setArgs(1);
    option.setArgName("domainID");
    this.options.addOption(option);
    option = new Option("r", "rank", true, Options.getMsg("clo.rank.txt"));
    option.setArgs(1);/*from   ww w.ja  v a  2  s . c om*/
    option.setArgName("rankNo");
    this.options.addOption(option);
    option = new Option("s", "size", true, Options.getMsg("clo.size.txt"));
    option.setArgs(1);
    option.setArgName("X>x<Y");
    this.options.addOption(option);
    this.toOpen = null;
}

From source file:com.paxxis.cornerstone.messaging.service.shell.ServiceShell.java

private Options initialize(String[] args) {
    OptionGroup group = new OptionGroup();

    Option helpOpt = new Option(null, "help", false, "this message");
    helpOpt.setArgs(2);
    helpOpt.setValueSeparator(',');
    group.addOption(helpOpt);//w  ww.  j av a2  s.c o m

    Option opt = new Option("sh", "shutdown", true, "the service to shut down");
    opt.setArgs(2);
    opt.setValueSeparator(',');
    group.addOption(opt);

    Option updateOpt = new Option(null, "dbupdate", false, "the database update parameters");
    updateOpt.setArgs(3);
    updateOpt.setValueSeparator(',');
    group.addOption(updateOpt);

    Option unbindOpt = new Option(null, "unbind", true,
            "the unbind option to be used ONLY if the service cannot be shut down gracefully");
    unbindOpt.setArgs(2);
    unbindOpt.setValueSeparator(',');
    group.addOption(unbindOpt);
    addOptions(group);

    Options options = new Options();
    options.addOptionGroup(group);
    return options;
}

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

/**
 * Parses the command line argument./*from   ww w.  j a  va2s. 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);
}

From source file:net.ripe.rpki.validator.cli.CommandLineOptions.java

private void addCommandGroup() {
    OptionGroup group = new OptionGroup();

    Option helpOption = new Option("h", HELP, false, "Show usage information");
    group.addOption(helpOption);/*w w w  .ja  v  a 2  s. c  om*/

    Option versionOption = new Option(null, VERSION, false, "Show version information");
    group.addOption(versionOption);

    Option printOption = new Option("p", PRINT, false,
            "Show the certificate repository object in a readable format");
    group.addOption(printOption);

    Option talOption = new Option("t", TAL, true,
            "Trust Anchor Locator (TAL). Can be specified more than once.");
    talOption.setArgs(Option.UNLIMITED_VALUES);
    group.addOption(talOption);

    group.setRequired(true);
    options.addOptionGroup(group);
}

From source file:it.jnrpe.plugins.factory.COption.java

Option toOption() {
    Option ret = new Option(m_sOption, m_sDescription);

    if (m_bArgsOptional != null)
        ret.setOptionalArg(m_bArgsOptional.booleanValue());

    if (m_bHasArgs) {
        if (m_iArgsCount == null)
            ret.setArgs(Option.UNLIMITED_VALUES);
    }//from   w  ww .ja  va 2s . com

    ret.setRequired(m_bRequired);
    if (m_iArgsCount != null)
        ret.setArgs(m_iArgsCount.intValue());

    if (m_sArgName != null) {
        if (m_iArgsCount == null)
            ret.setArgs(Option.UNLIMITED_VALUES);
        ret.setArgName(m_sArgName);
    }

    if (m_sLongOpt != null)
        ret.setLongOpt(m_sLongOpt);

    if (m_sValueSeparator != null && m_sValueSeparator.length() != 0)
        ret.setValueSeparator(m_sValueSeparator.charAt(0));

    return ret;
}

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

/**
 * Get the options./*  w w  w . ja v  a 2 s.  co m*/
 * 
 * @return the specific CrawlToCsv options
 */
@Override
protected Options getOptions() {
    final Options options = super.getOptions();

    final Option filenameOption = new Option("f",
            "the name of the csv output file, default name is " + DEFAULT_FILENAME + " [optional]");
    filenameOption.setArgName("FILENAME");
    filenameOption.setLongOpt("filename");
    filenameOption.setRequired(false);
    filenameOption.setArgs(1);

    options.addOption(filenameOption);

    return options;

}