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

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

Introduction

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

Prototype

public void setType(Object type) 

Source Link

Document

Sets the type of this Option.

Usage

From source file:edu.cornell.med.icb.R.RUtils.java

public static void main(final String[] args) throws ParseException, ConfigurationException {
    final Options options = new Options();

    final Option helpOption = new Option("h", "help", false, "Print this message");
    options.addOption(helpOption);//from   ww w .  j a v  a 2s  .  c om

    final Option startupOption = new Option(Mode.startup.name(), Mode.startup.name(), false,
            "Start Rserve process");
    final Option shutdownOption = new Option(Mode.shutdown.name(), Mode.shutdown.name(), false,
            "Shutdown Rserve process");
    final Option validateOption = new Option(Mode.validate.name(), Mode.validate.name(), false,
            "Validate that Rserve processes are running");

    final OptionGroup optionGroup = new OptionGroup();
    optionGroup.addOption(startupOption);
    optionGroup.addOption(shutdownOption);
    optionGroup.addOption(validateOption);
    optionGroup.setRequired(true);
    options.addOptionGroup(optionGroup);

    final Option portOption = new Option("port", "port", true,
            "Use specified port to communicate with the Rserve process");
    portOption.setArgName("port");
    portOption.setType(int.class);
    options.addOption(portOption);

    final Option hostOption = new Option("host", "host", true,
            "Communicate with the Rserve process on the given host");
    hostOption.setArgName("hostname");
    hostOption.setType(String.class);
    options.addOption(hostOption);

    final Option userOption = new Option("u", "username", true, "Username to send to the Rserve process");
    userOption.setArgName("username");
    userOption.setType(String.class);
    options.addOption(userOption);

    final Option passwordOption = new Option("p", "password", true, "Password to send to the Rserve process");
    passwordOption.setArgName("password");
    passwordOption.setType(String.class);
    options.addOption(passwordOption);

    final Option configurationOption = new Option("c", "configuration", true,
            "Configuration file or url to read from");
    configurationOption.setArgName("configuration");
    configurationOption.setType(String.class);
    options.addOption(configurationOption);

    final Parser parser = new BasicParser();
    final CommandLine commandLine;
    try {
        commandLine = parser.parse(options, args);
    } catch (ParseException e) {
        usage(options);
        throw e;
    }

    int exitStatus = 0;
    if (commandLine.hasOption("h")) {
        usage(options);
    } else {
        Mode mode = null;
        for (final Mode potentialMode : Mode.values()) {
            if (commandLine.hasOption(potentialMode.name())) {
                mode = potentialMode;
                break;
            }
        }

        final ExecutorService threadPool = Executors.newCachedThreadPool();

        if (commandLine.hasOption("configuration")) {
            final String configurationFile = commandLine.getOptionValue("configuration");
            LOG.info("Reading configuration from " + configurationFile);
            XMLConfiguration configuration;
            try {
                final URL configurationURL = new URL(configurationFile);
                configuration = new XMLConfiguration(configurationURL);
            } catch (MalformedURLException e) {
                // resource is not a URL: attempt to get the resource from a file
                LOG.debug("Configuration is not a valid url");
                configuration = new XMLConfiguration(configurationFile);
            }

            configuration.setValidating(true);
            final int numberOfRServers = configuration.getMaxIndex("RConfiguration.RServer") + 1;
            boolean failed = false;
            for (int i = 0; i < numberOfRServers; i++) {
                final String server = "RConfiguration.RServer(" + i + ")";
                final String host = configuration.getString(server + "[@host]");
                final int port = configuration.getInt(server + "[@port]",
                        RConfigurationUtils.DEFAULT_RSERVE_PORT);
                final String username = configuration.getString(server + "[@username]");
                final String password = configuration.getString(server + "[@password]");
                final String command = configuration.getString(server + "[@command]", DEFAULT_RSERVE_COMMAND);

                if (executeMode(mode, threadPool, host, port, username, password, command) != 0) {
                    failed = true; // we have other hosts to check so keep a failed state
                }
            }
            if (failed) {
                exitStatus = 3;
            }
        } else {
            final String host = commandLine.getOptionValue("host", "localhost");
            final int port = Integer.valueOf(commandLine.getOptionValue("port", "6311"));
            final String username = commandLine.getOptionValue("username");
            final String password = commandLine.getOptionValue("password");

            exitStatus = executeMode(mode, threadPool, host, port, username, password, null);
        }
        threadPool.shutdown();
    }

    System.exit(exitStatus);
}

From source file:au.id.hazelwood.xmltvguidebuilder.runner.Main.java

private static Option createOptionWithArg(String opt, boolean required, String argName, Class<?> argType,
        String description) {// w  w w .j a v  a 2s .co  m
    Option option = new Option(opt, true, description);
    option.setRequired(required);
    option.setArgName(argName);
    option.setType(argType);
    return option;
}

From source file:cz.muni.fi.crocs.EduHoc.OptionsMain.java

public static Options createOptions() {
    Option help = new Option("h", "help", false, "show help and exit");

    Option motes = new Option("a", "motes", true,
            "path to alternative file of motes, default setting is stored in confix/motePaths.txt");
    Option ids = new Option("i", "id", true,
            "select IDs of nodes from motelist, use comma separated list of IDs or ID ranges, such as 1,3,5-7,9-15");

    Option detect = new Option("d", "detect", false, "Perform node detection only");

    Option verbose = new Option("v", "verbose", false, "show extended text output");
    Option silent = new Option("s", "silent", false, "show limited text output");
    OptionGroup output = new OptionGroup();
    output.addOption(verbose);/*from  w  w  w .  j  a v  a 2s .co  m*/
    output.addOption(silent);

    Option make = new Option("m", "make", true, "make target at this path, directory must contain Makefile");
    Option makeClean = new Option("c", "make_clean", true,
            "make clean target at this path, directory must contain Makefile");
    Option makeUpload = new Option("u", "make_upload", true,
            "make target  at this path and upload to nodes, directory must contain Makefile");
    Option threads = new Option("t", "threads", false, "use threads for paralell upload");

    OptionGroup makeGroup = new OptionGroup();
    makeGroup.addOption(make);
    makeGroup.addOption(makeUpload);
    makeGroup.addOption(makeClean);

    Option listen = new Option("l", "listen", true,
            "connect to serial and save stream to files, set path to directory for files");
    Option write = new Option("w", "write", true,
            "write to serial now or after upload, directory must contain at least one file with same name as node");

    Option execute = new Option("E", "execute", true, "path to shell script to be executed in phase 3");
    Option time = new Option("T", "time", true,
            "countdown in minutes for serial phase, default is 15 minutes, after this time, serial connection closes");
    time.setType(int.class);

    Options options = new Options();

    options.addOption(help);
    options.addOption(motes);
    options.addOption(ids);
    options.addOption(detect);

    options.addOptionGroup(output);

    options.addOptionGroup(makeGroup);

    options.addOption(threads);
    options.addOption(write);
    options.addOption(listen);

    options.addOption(execute);
    options.addOption(time);

    return options;
}

From source file:com.tc.config.schema.setup.StandardConfigurationSetupManagerFactory.java

public static Options createOptions(ConfigMode configMode) {
    Options options = new Options();

    Option configFileOption = new Option("f", CONFIG_SPEC_ARGUMENT_NAME, true,
            "the configuration file to use, specified as a file path or URL");
    configFileOption.setArgName("file-or-URL");
    configFileOption.setType(String.class);

    if (configMode == ConfigMode.L2) {
        configFileOption.setRequired(false);
        options.addOption(configFileOption);

        Option l2NameOption = new Option("n", "name", true, "the name of this L2; defaults to the host name");
        l2NameOption.setRequired(false);
        l2NameOption.setArgName("l2-name");
        options.addOption(l2NameOption);
    } else {/*from  w  ww.  ja v  a  2  s. c  om*/
        configFileOption.setRequired(true);
        options.addOption(configFileOption);
    }

    return options;
}

From source file:lanchon.dexpatcher.Parser.java

private static Options getOptions() {

    Options options = new Options();
    Option o;

    o = new Option("o", "output", true, "name of output file or directory");
    o.setArgName("dex-or-dir");
    options.addOption(o);//from   www  .  ja  v a  2 s . c  om

    o = new Option("a", "api-level", true, "android api level (default: auto-detect)");
    o.setArgName("n");
    o.setType(Number.class);
    options.addOption(o);

    options.addOption(new Option("m", "multi-dex", false, "enable multi-dex support"));
    options.addOption(new Option("M", "multi-dex-threaded", false, "multi-threaded multi-dex (implies: -m)"));
    o = new Option("J", "multi-dex-jobs", true, "multi-dex thread count (implies: -m -M) (default: "
            + "available processors up to " + MultiDexIO.DEFAULT_MAX_THREADS + ")");
    o.setArgName("n");
    o.setType(Number.class);
    options.addOption(o);

    o = new Option(null, "max-dex-pool-size", true,
            "maximum size of dex pools (default: " + DexIO.DEFAULT_MAX_DEX_POOL_SIZE + ")");
    o.setArgName("n");
    o.setType(Number.class);
    options.addOption(o);

    o = new Option(null, "annotations", true,
            "package name of DexPatcher annotations (default: '" + Context.DEFAULT_ANNOTATION_PACKAGE + "')");
    o.setArgName("package");
    options.addOption(o);
    options.addOption(new Option(null, "compat-dextag", false, "enable support for the deprecated DexTag"));

    options.addOption(new Option("q", "quiet", false, "do not output warnings"));
    options.addOption(new Option("v", "verbose", false, "output extra information"));
    options.addOption(new Option(null, "debug", false, "output debugging information"));

    options.addOption(new Option("p", "path", false, "output relative paths of source code files"));
    o = new Option(null, "path-root", true, "output absolute paths of source code files");
    o.setArgName("root");
    options.addOption(o);
    options.addOption(new Option(null, "stats", false, "output timing statistics"));

    options.addOption(new Option(null, "dry-run", false, "do not write output files (much faster)"));

    options.addOption(new Option(null, "version", false, "print version information and exit"));
    options.addOption(new Option("?", "help", false, "print this help message and exit"));

    return options;

}

From source file:com.fatwire.dta.sscrawler.App.java

@SuppressWarnings("static-access")
public static Options setUpCmd() {
    final Options options = new Options();

    options.addOption("h", "help", false, "print this message.");

    final Option reportDir = OptionBuilder.withArgName("dir").hasArg()
            .withDescription("Directory where reports are stored").withLongOpt("reportDir").create("d");
    options.addOption(reportDir);/*from w  w  w.  j  a v  a  2 s. c  o m*/

    final Option max = OptionBuilder.withArgName("num").hasArg()
            .withDescription("Maximum number of pages, default is unlimited").withLongOpt("max").create("m");
    options.addOption(max);

    final Option uriHelperFactory = OptionBuilder.withArgName("classname").hasArg()
            .withDescription("Class for constructing urls").withLongOpt("uriHelperFactory").create("f");
    uriHelperFactory.setType(UriHelperFactory.class);
    options.addOption(uriHelperFactory);

    final Option threads = OptionBuilder.withArgName("num").hasArg()
            .withDescription("Number of concurrent threads that are reading from ContentServer")
            .withLongOpt("threads").create("t");
    options.addOption(threads);

    final Option proxyUsername = OptionBuilder.withArgName("username").hasArg()
            .withDescription("Proxy Username").withLongOpt("proxyUsername").create("pu");
    options.addOption(proxyUsername);

    final Option proxyPassword = OptionBuilder.withArgName("password").hasArg()
            .withDescription("Proxy Password").withLongOpt("proxyPassword").create("pw");
    options.addOption(proxyPassword);

    final Option proxyHost = OptionBuilder.withArgName("host").hasArg().withDescription("Proxy hostname")
            .withLongOpt("proxyHost").create("ph");
    options.addOption(proxyHost);

    final Option proxyPort = OptionBuilder.withArgName("port").hasArg().withDescription("Proxy port number")
            .withLongOpt("proxyPort").create("pp");
    options.addOption(proxyPort);
    return options;

}

From source file:com.twitter.heron.instance.HeronInstance.java

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

    Option topologyNameOption = new Option(CommandLineOptions.TOPOLOGY_NAME_OPTION, true, "Topology Name");
    topologyNameOption.setRequired(true);
    topologyNameOption.setType(String.class);
    options.addOption(topologyNameOption);

    Option topologyIdOption = new Option(CommandLineOptions.TOPOLOGY_ID_OPTION, true, "Topology ID");
    topologyIdOption.setRequired(true);/*from ww w.j a  va  2 s . com*/
    topologyIdOption.setType(String.class);
    options.addOption(topologyIdOption);

    Option instanceIdOption = new Option(CommandLineOptions.INSTANCE_ID_OPTION, true, "Instance ID");
    instanceIdOption.setRequired(true);
    instanceIdOption.setType(String.class);
    options.addOption(instanceIdOption);

    Option componentNameOption = new Option(CommandLineOptions.COMPONENT_NAME_OPTION, true, "Component Name");
    componentNameOption.setRequired(true);
    componentNameOption.setType(String.class);
    options.addOption(componentNameOption);

    Option taskIdOption = new Option(CommandLineOptions.TASK_ID_OPTION, true, "Task ID");
    taskIdOption.setRequired(true);
    taskIdOption.setType(Integer.class);
    options.addOption(taskIdOption);

    Option componentIndexOption = new Option(CommandLineOptions.COMPONENT_INDEX_OPTION, true,
            "Component Index");
    componentIndexOption.setRequired(true);
    componentIndexOption.setType(Integer.class);
    options.addOption(componentIndexOption);

    Option stmgrIdOption = new Option(CommandLineOptions.STMGR_ID_OPTION, true, "Stream Manager ID");
    stmgrIdOption.setType(String.class);
    stmgrIdOption.setRequired(true);
    options.addOption(stmgrIdOption);

    Option stmgrPortOption = new Option(CommandLineOptions.STMGR_PORT_OPTION, true, "Stream Manager Port");
    stmgrPortOption.setType(Integer.class);
    stmgrPortOption.setRequired(true);
    options.addOption(stmgrPortOption);

    Option metricsmgrPortOption = new Option(CommandLineOptions.METRICS_MGR_PORT_OPTION, true,
            "Metrics Manager Port");
    metricsmgrPortOption.setType(Integer.class);
    metricsmgrPortOption.setRequired(true);
    options.addOption(metricsmgrPortOption);

    Option systemConfigFileOption = new Option(CommandLineOptions.SYSTEM_CONFIG_FILE, true,
            "Heron Internals Config Filename");
    systemConfigFileOption.setType(String.class);
    systemConfigFileOption.setRequired(true);
    options.addOption(systemConfigFileOption);

    Option overrideConfigFileOption = new Option(CommandLineOptions.OVERRIDE_CONFIG_FILE, true,
            "Override Config File");
    overrideConfigFileOption.setType(String.class);
    overrideConfigFileOption.setRequired(true);
    options.addOption(overrideConfigFileOption);

    Option remoteDebuggerPortOption = new Option(CommandLineOptions.REMOTE_DEBUGGER_PORT, true,
            "Remote Debugger Port");
    remoteDebuggerPortOption.setType(Integer.class);
    options.addOption(remoteDebuggerPortOption);

    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("Heron Instance", options);
        throw new RuntimeException("Incorrect Usage");
    }
    return cmd;
}

From source file:fr.inria.atlanmod.dag.instantiator.Launcher.java

/**
 * Configures the program options//from   w  ww .j a v  a2  s  .  co m
 *
 * @param options
 */
private static void configureOptions(Options options) {

    Option outDirOpt = OptionBuilder.create(OUTPUT_PATH);
    outDirOpt.setLongOpt(OUTPUT_PATH_LONG);
    outDirOpt.setArgName("neoEMF output uri");
    outDirOpt.setDescription("Output directory (defaults to working dir)");
    outDirOpt.setArgs(1);
    outDirOpt.setRequired(true);

    Option nModelsOpt = OptionBuilder.create(N_MODELS);
    nModelsOpt.setLongOpt(N_MODELS_LONG);
    nModelsOpt.setArgName("models");
    nModelsOpt.setDescription("Number of generated models (defaults to 1)");
    nModelsOpt.setType(Number.class);
    nModelsOpt.setArgs(1);

    Option sizeOption = OptionBuilder.create(SIZE);
    sizeOption.setLongOpt(SIZE_LONG);
    sizeOption.setArgName("size");
    sizeOption.setDescription(MessageFormat.format("Average models'' size (defaults to {0})",
            Launcher.DEFAULT_AVERAGE_MODEL_SIZE));
    sizeOption.setType(Number.class);
    sizeOption.setArgs(1);

    Option densityOption = OptionBuilder.create(VARIATION);
    densityOption.setLongOpt(VARIATION_LONG);
    densityOption.setArgName("proportion");
    densityOption.setDescription(MessageFormat
            .format("Variation ([0..1]) in the models'' size (defaults to {0})", Launcher.DEFAULT_DEVIATION));
    densityOption.setType(Number.class);
    densityOption.setArgs(1);

    Option propVariationOption = OptionBuilder.create(PROP_VARIATION);
    propVariationOption.setLongOpt(PROP_VARIATION_LONG);
    propVariationOption.setArgName("properties deviation");
    propVariationOption.setDescription(MessageFormat.format(
            "Variation ([0..1]) in the properties'' size (defaults to {0})", Launcher.DEFAULT_DEVIATION));
    propVariationOption.setType(Number.class);
    propVariationOption.setArgs(1);

    Option seedOption = OptionBuilder.create(SEED);
    seedOption.setLongOpt(SEED_LONG);
    seedOption.setArgName("seed");
    seedOption.setDescription("Seed number (random by default)");
    seedOption.setType(Number.class);
    seedOption.setArgs(1);

    Option valuesSizeOption = OptionBuilder.create(VALUES_SIZE);
    valuesSizeOption.setLongOpt(VALUES_SIZE_LONG);
    valuesSizeOption.setArgName("size");
    valuesSizeOption.setDescription(MessageFormat.format(
            "Average size for attributes with variable length (defaults to {0}). Actual sizes may vary +/- {1}%.",
            GenericMetamodelConfig.DEFAULT_AVERAGE_VALUES_LENGTH,
            GenericMetamodelConfig.DEFAULT_VALUES_DEVIATION * 100));
    valuesSizeOption.setType(Number.class);
    valuesSizeOption.setArgs(1);

    Option degreeOption = OptionBuilder.create(DEGREE);
    degreeOption.setLongOpt(DEGREE_LONG);
    degreeOption.setArgName("degree");
    degreeOption.setDescription(MessageFormat.format(
            "Average number of references per EObject (defaults to {0}). Actual sizes may vary +/- {1}%.",
            GenericMetamodelConfig.DEFAULT_AVERAGE_REFERENCES_SIZE,
            GenericMetamodelConfig.DEFAULT_REFERENCES_DEVIATION * 100));
    degreeOption.setType(Number.class);
    degreeOption.setArgs(1);

    Option forceOption = OptionBuilder.create(FORCE);
    forceOption.setLongOpt(FORCE_LONG);
    forceOption.setDescription("Force the generation, even if input metamodels contain errors");

    Option diagnoseOption = OptionBuilder.create(DIAGNOSE);
    diagnoseOption.setLongOpt(DIAGNOSE_LONG);
    diagnoseOption.setDescription("Run diagnosis on the result model");

    options.addOption(outDirOpt);
    options.addOption(nModelsOpt);
    options.addOption(sizeOption);
    options.addOption(propVariationOption);
    options.addOption(valuesSizeOption);
    options.addOption(degreeOption);
    options.addOption(seedOption);
    options.addOption(forceOption);
    options.addOption(diagnoseOption);
    options.addOption(densityOption);
}

From source file:fr.inria.atlanmod.instantiator.neoEMF.Launcher.java

/**
 * Configures the program options/* w ww .jav a 2s  .  c o  m*/
 *
 * @param options
 */
private static void configureOptions(Options options) {
    Option metamodelOpt = OptionBuilder.create(E_PACKAGE_CLASS);
    metamodelOpt.setLongOpt(E_PACKAGE_CLASS_LONG);
    metamodelOpt.setArgName("path to the ePackage implementation");
    metamodelOpt.setDescription("PackgeImpl");
    metamodelOpt.setArgs(1);
    metamodelOpt.setRequired(true);

    Option outDirOpt = OptionBuilder.create(OUTPUT_PATH);
    outDirOpt.setLongOpt(OUTPUT_PATH_LONG);
    outDirOpt.setArgName("neoEMF output uri");
    outDirOpt.setDescription("Output directory (defaults to working dir)");
    outDirOpt.setArgs(1);
    outDirOpt.setRequired(true);

    Option nModelsOpt = OptionBuilder.create(N_MODELS);
    nModelsOpt.setLongOpt(N_MODELS_LONG);
    nModelsOpt.setArgName("models");
    nModelsOpt.setDescription("Number of generated models (defaults to 1)");
    nModelsOpt.setType(Number.class);
    nModelsOpt.setArgs(1);

    Option sizeOption = OptionBuilder.create(SIZE);
    sizeOption.setLongOpt(SIZE_LONG);
    sizeOption.setArgName("size");
    sizeOption.setDescription(MessageFormat.format("Average models'' size (defaults to {0})",
            Launcher.DEFAULT_AVERAGE_MODEL_SIZE));
    sizeOption.setType(Number.class);
    sizeOption.setArgs(1);

    Option variationOption = OptionBuilder.create(VARIATION);
    variationOption.setLongOpt(VARIATION_LONG);
    variationOption.setArgName("proportion");
    variationOption.setDescription(MessageFormat
            .format("Variation ([0..1]) in the models'' size (defaults to {0})", Launcher.DEFAULT_DEVIATION));
    variationOption.setType(Number.class);
    variationOption.setArgs(1);

    Option propVariationOption = OptionBuilder.create(PROP_VARIATION);
    propVariationOption.setLongOpt(PROP_VARIATION_LONG);
    propVariationOption.setArgName("properties deviation");
    propVariationOption.setDescription(MessageFormat.format(
            "Variation ([0..1]) in the properties'' size (defaults to {0})", Launcher.DEFAULT_DEVIATION));
    propVariationOption.setType(Number.class);
    propVariationOption.setArgs(1);

    Option seedOption = OptionBuilder.create(SEED);
    seedOption.setLongOpt(SEED_LONG);
    seedOption.setArgName("seed");
    seedOption.setDescription("Seed number (random by default)");
    seedOption.setType(Number.class);
    seedOption.setArgs(1);

    Option valuesSizeOption = OptionBuilder.create(VALUES_SIZE);
    valuesSizeOption.setLongOpt(VALUES_SIZE_LONG);
    valuesSizeOption.setArgName("size");
    valuesSizeOption.setDescription(MessageFormat.format(
            "Average size for attributes with variable length (defaults to {0}). Actual sizes may vary +/- {1}%.",
            GenericMetamodelConfig.DEFAULT_AVERAGE_VALUES_LENGTH,
            GenericMetamodelConfig.DEFAULT_VALUES_DEVIATION * 100));
    valuesSizeOption.setType(Number.class);
    valuesSizeOption.setArgs(1);

    Option degreeOption = OptionBuilder.create(DEGREE);
    degreeOption.setLongOpt(DEGREE_LONG);
    degreeOption.setArgName("degree");
    degreeOption.setDescription(MessageFormat.format(
            "Average number of references per EObject (defaults to {0}). Actual sizes may vary +/- {1}%.",
            GenericMetamodelConfig.DEFAULT_AVERAGE_REFERENCES_SIZE,
            GenericMetamodelConfig.DEFAULT_REFERENCES_DEVIATION * 100));
    degreeOption.setType(Number.class);
    degreeOption.setArgs(1);

    Option forceOption = OptionBuilder.create(FORCE);
    forceOption.setLongOpt(FORCE_LONG);
    forceOption.setDescription("Force the generation, even if input metamodels contain errors");

    Option diagnoseOption = OptionBuilder.create(DIAGNOSE);
    diagnoseOption.setLongOpt(DIAGNOSE_LONG);
    diagnoseOption.setDescription("Run diagnosis on the result model");

    options.addOption(metamodelOpt);
    options.addOption(outDirOpt);
    options.addOption(nModelsOpt);
    options.addOption(sizeOption);
    options.addOption(variationOption);
    options.addOption(propVariationOption);
    options.addOption(valuesSizeOption);
    options.addOption(degreeOption);
    options.addOption(seedOption);
    options.addOption(forceOption);
    options.addOption(diagnoseOption);
}

From source file:de.iew.imageread.Main.java

protected static Options setupOptions() {
    Options options = new Options();

    Option imageOutputDirOption = new Option("o", "outputDir", true,
            "The base directory to write the images to (Default: system temp directory)");
    imageOutputDirOption.setArgName("outputDir");

    Option imageFilenamePrefixOption = new Option("p", "filenamePrefix", true,
            "The basename/prefix for each image (Default: image-)");
    imageFilenamePrefixOption.setArgName("filenamePrefix");

    Option groupingOutputOption = new Option("g", "groupingOutput", true,
            "Grouping option for the images; valid values are ALL, GROUP_BY_DAY (Default: ALL)");
    groupingOutputOption.setArgName("groupingOutput");
    groupingOutputOption.setType(OUTPUT_OPTION.class);

    Option queryOption = new Option("q", "query", true,
            "Query filters for the mongo db queries; valid values for 'query' are FROM, TO and EXACT (Default: no specific query)");
    queryOption.setArgs(2);/*  w ww  .  j a  v  a2s.  co  m*/
    queryOption.setArgName("query=date");
    queryOption.setValueSeparator('=');

    Option databaseOption = new Option("md", "database", true, "The mongo db database (Default: test)");
    databaseOption.setArgName("database");

    Option mongodbHostOption = new Option("mh", "hostname", true,
            "The hostname of the mongo db instance (Default: localhost)");
    mongodbHostOption.setArgName("hostname");

    Option mongodbPortOption = new Option("mp", "port", true,
            "The port of the mongo db instance (Default: 27017)");
    mongodbPortOption.setArgName("port");
    mongodbPortOption.setType(Integer.TYPE);

    Option printHelpOption = new Option("h", "help", false, "Print help");

    options.addOption(imageOutputDirOption);
    options.addOption(imageFilenamePrefixOption);
    options.addOption(groupingOutputOption);
    options.addOption(queryOption);
    options.addOption(databaseOption);
    options.addOption(mongodbHostOption);
    options.addOption(mongodbPortOption);

    options.addOption(printHelpOption);

    return options;
}