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

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

Introduction

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

Prototype

public void setRequired(boolean required) 

Source Link

Document

Sets whether this Option is mandatory.

Usage

From source file:com.revolsys.gis.tools.ProcessorPipelineTool.java

private void newOptions() {
    final Option script = new Option(SCRIPT_OPTION, SCRIPT, true,
            "the script file that defines the processor pipeline");
    script.setRequired(true);
    this.options.addOption(script);

    final Option sourceDirectory = new Option(SOURCE_DIRECTORY_OPTION, SOURCE_DIRECTORY, true,
            "the location of the source files to process");
    sourceDirectory.setRequired(false);//from  w  w w.  ja v  a2s. c  o  m
    this.options.addOption(sourceDirectory);

    final Option sourceFileExtension = new Option(SOURCE_FILE_EXTENSION_OPTION, SOURCE_FLE_EXTENSION, true,
            "the file extension of the source files (e.g. .saf)");
    sourceFileExtension.setRequired(false);
    this.options.addOption(sourceFileExtension);

    final Option outputDirectory = new Option(OUTPUT_DIRECTORY_OPTION, OUTPUT_DIRECTORY, true,
            "the directory to write processed files to");
    outputDirectory.setRequired(false);
    this.options.addOption(outputDirectory);

    final Option logDirectory = new Option(LOG_DIRECTORY_OPTION, LOG_DIRECTORY, true,
            "the directory to write log files to");
    logDirectory.setRequired(false);
    this.options.addOption(logDirectory);

    final Option excludePattern = new Option(EXCLUDE_PATTERN_OPTION, EXCLUDE_PATTERN, true,
            "exclude files matching a regular expression (e.g. '.*_back.zip");
    excludePattern.setRequired(false);
    this.options.addOption(excludePattern);

    final Option property = new Option("D", "property=value", true, "use value for given property");
    property.setValueSeparator('=');
    this.options.addOption(property);
}

From source file:de.uni_koblenz.jgralab.gretl.GReTLRunner.java

public GReTLRunner() {
    String toolString = "java " + GReTLRunner.class.getName();
    String versionString = JGraLab.getInfo(false);

    oh = new OptionHandler(toolString, versionString);
    Option transform = new Option("t", "transformation", true,
            "(required) The GReTL transformation that should be executed.");
    transform.setArgName("gretl-file");
    transform.setRequired(true);
    oh.addOption(transform);/*from  w  w  w  .  ja  v  a 2s .  c om*/

    Option schema = new Option("s", "schema", true,
            "(optional) The name of the target schema. " + "Defaults to foo.bar.BazSchema.");
    schema.setArgName("schema-name");
    schema.setRequired(false);
    oh.addOption(schema);

    Option graphclass = new Option("g", "graphclass", true,
            "(optional) The name of the target graph class. " + "Defaults to BazGraph.");
    graphclass.setArgName("graphclass");
    graphclass.setRequired(false);
    oh.addOption(graphclass);

    Option viz = new Option("z", "visualize", false,
            "(optional) Additionally create a PDF viz of the output graph.");
    viz.setRequired(false);
    oh.addOption(viz);

    Option reverseViz = new Option("r", "reverse-edges", false,
            "(optional) When -z is given, print edges pointing bottom-up.");
    reverseViz.setRequired(false);
    oh.addOption(reverseViz);

    Option debugExecution = new Option("d", "debug", false,
            "(optional) Print the target graph after each transformation op.");
    debugExecution.setRequired(false);
    oh.addOption(debugExecution);

    Option output = new Option("o", "output", true,
            "(optional) The file to store the target graph to.  If many input "
                    + "models are to be transformed, this has no effect.");
    output.setRequired(false);
    debugExecution.setArgName("target-graph-file");
    oh.addOption(output);

    // TODO: Basically, -u should exclude the usage of -s/-g.
    Option useSourceSchema = new Option("u", "use-source-schema", false,
            "(optional) Use the source schema as target schema. "
                    + "In that case, no schema modifications may be performed by the transformation.");
    useSourceSchema.setRequired(false);
    oh.addOption(useSourceSchema);

    // TODO: Basically, -i should exclude the usage of -s/-g.
    Option inPlace = new Option("i", "in-place", false, "(optional) Use the source graph as target graph. "
            + "In that case, no schema modifications may be performed by the transformation.");
    inPlace.setRequired(false);
    oh.addOption(inPlace);

    oh.setArgumentCount(Option.UNLIMITED_VALUES);
    oh.setArgumentName("input-graph");
    oh.setOptionalArgument(false);
}

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);
    }/*  w w  w .  j  a va 2  s.  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:edu.cornell.med.icb.geo.tools.CalculateRanks.java

private void proccess(final String[] args) throws IOException {
    // create the Options
    final Options options = new Options();

    // help//from   ww  w  . j  a v a  2  s  . c  o m
    options.addOption("h", "help", false,
            "print this message. This program compares the performance measures obtained "
                    + "with each gene list and determines the rank of each gene list.");

    // input file name
    final Option inputOption = new Option("i", "input", true,
            "specify the path to the statistics file created by MicroarrayTrainEvaluate.");
    inputOption.setArgName("file");
    inputOption.setRequired(true);
    options.addOption(inputOption);

    // output file name
    final Option outputOption = new Option("o", "output", true,
            "specify the destination file where post-processed statistics will be written");
    outputOption.setArgName("file");
    outputOption.setRequired(true);
    options.addOption(outputOption);

    // tallies file name
    final Option talliesOption = new Option("t", "tallies", true,
            "specify the file where tallies of rank per gene list will be written");
    talliesOption.setArgName("file");
    talliesOption.setRequired(false);
    options.addOption(talliesOption);

    // filter by shuffle test P-value
    final Option filterShuffleTestOption = new Option("f", "filter-shuffle-test", false,
            "indicate that only those results that pass the shuffle significance test should be used to calculate ranks and tallies.");
    filterShuffleTestOption.setRequired(false);

    options.addOption(filterShuffleTestOption);

    // parse the command line arguments
    CommandLine line = null;
    try {
        // create the command line parser
        final CommandLineParser parser = new BasicParser();
        line = parser.parse(options, args, true);

    } catch (ParseException e) {
        System.err.println(e.getMessage());
        usage(options);
        System.exit(1);
    }
    // print help and exit
    if (line.hasOption("h")) {
        usage(options);
        System.exit(0);
    }
    this.filterWithShuffleTest = line.hasOption("f");
    if (this.filterWithShuffleTest) {
        System.out.println("Filtering classification results by shuffle test.");
    }
    postProcess(line.getOptionValue("i"), line.getOptionValue("o"), line.getOptionValue("t"));
}

From source file:de.yaio.commons.cli.CmdLineHelper.java

/**
 * <h1>Bereich:</h1>/* www .ja v  a2 s .  c  o m*/
 *     Tools - CLI-Config
 * <h1>Funktionalitaet:</h1>
 *     konfiguriert die verfuegbaren Base-CLI-Optionen
 * <h1>Nebenwirkungen:</h1>
 *     aktualisiert availiableCmdLineOptions
 * @param availiableCmdLineOptions Options
 */
public void addAvailiableBaseCmdLineOptions(final Options availiableCmdLineOptions) {
    // Config-File
    Option configOption = new Option(null, "config", true, "comma separated list of JobConfig property files");
    configOption.setRequired(true);
    availiableCmdLineOptions.addOption(configOption);

    // Hilfe-ConfigurationOption
    Option helpOption = new Option("h", "help", false, "usage");
    helpOption.setRequired(false);
    availiableCmdLineOptions.addOption(helpOption);

    // debug-ConfigurationOption
    Option debugOption = new Option(null, "debug", false, "debug");
    debugOption.setRequired(false);
    availiableCmdLineOptions.addOption(debugOption);
}

From source file:net.es.nsi.topology.translator.Options.java

/**
 * Build supported command line options for parsing of parameter input.
 *
 * @return List of supported command line options.
 *//*from   w w w. ja  v  a2s.c  o m*/
private org.apache.commons.cli.Options getOptions() {
    // Create Options object to hold our command line options.
    org.apache.commons.cli.Options options = new org.apache.commons.cli.Options();

    Option basedirOption = new Option(ARGNAME_BASEDIR, true,
            "The runtime home directory for the application (defaults to \"user.dir\").");
    basedirOption.setRequired(false);
    options.addOption(basedirOption);

    Option configdirOption = new Option(ARGNAME_CONFIGDIR, true,
            "Location of configuration directory (defaults to ./config).");
    configdirOption.setRequired(false);
    options.addOption(configdirOption);

    Option configfileOption = new Option(ARGNAME_CONFIGFILE, true,
            "Path to the translation configuration file.");
    configfileOption.setRequired(false);
    options.addOption(configfileOption);

    Option debugOption = new Option(ARGNAME_DEBUG, false, "If specified enables debug tracing in Jersey.");
    debugOption.setRequired(false);
    options.addOption(debugOption);

    return options;
}

From source file:co.cask.cdap.internal.app.runtime.distributed.AbstractProgramTwillRunnable.java

private Option createOption(String opt, String desc) {
    Option option = new Option(opt, true, desc);
    option.setRequired(true);
    return option;
}

From source file:com.spectralogic.ds3cli.Arguments.java

void addRootArguments() {
    for (final Option optionRoot : rootArgs) {
        optionRoot.setRequired(false);
        addOption(optionRoot, optionRoot.getArgName());
    }//from  w  w w . j a va2  s  . c om
}

From source file:ancat.console.ConsoleModelChecker.java

/**
 * Prepare the options processed from the command line
 * //  w w w.j a  v a2s.c o  m
 * @return an array of Options
 */
protected Options prepareOptions() {
    Options options = new Options();

    Option fileOption = new Option("f", true, "File containing the graph description");
    fileOption.setRequired(false);
    options.addOption(fileOption);

    Option inspectorOption = new Option("i", true, "Inspector to be used when analyzing the model");
    inspectorOption.setRequired(false);
    options.addOption(inspectorOption);

    Option configurationOption = new Option("c", true,
            "use xml based configuration file instead of -f and -i parameters");
    configurationOption.setRequired(false);
    options.addOption(configurationOption);

    Option config2Option = new Option("x", true, "configuration with new config file format");
    config2Option.setRequired(false);
    options.addOption(config2Option);

    return options;
}

From source file:kieker.tools.logReplayer.FilesystemLogReplayerStarter.java

@Override
protected void addAdditionalOptions(final Options options) {
    Option option;

    option = new Option("c", CMD_OPT_NAME_MONITORING_CONFIGURATION, true,
            "Configuration to use for the Kieker monitoring instance");
    option.setArgName(OPTION_EXAMPLE_FILE_MONITORING_PROPERTIES);
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);/*from   w ww  .j  ava2  s . c o m*/

    option = new Option("i", CMD_OPT_NAME_INPUTDIRS, true, "Log directories to read data from");
    option.setArgName("dir1 ... dirN");
    option.setRequired(false);
    option.setArgs(Option.UNLIMITED_VALUES);
    options.addOption(option);

    option = new Option("k", CMD_OPT_NAME_KEEPORIGINALLOGGINGTIMESTAMPS, true,
            "Replay the original logging timestamps (defaults to true)?");
    option.setArgName("true|false");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option("r", CMD_OPT_NAME_REALTIME, true, "Replay log data in realtime?");
    option.setArgName("true|false");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option("n", CMD_OPT_NAME_NUM_REALTIME_WORKERS, true,
            "Number of worker threads used in realtime mode (defaults to 1).");
    option.setArgName("num");
    option.setRequired(false);
    options.addOption(option);

    option = new Option("a", CMD_OPT_NAME_REALTIME_ACCELERATION_FACTOR, true,
            "Factor by which to accelerate (>1.0) or slow down (<1.0) the replay in realtime mode (defaults to 1.0, i.e., no acceleration/slow down).");
    option.setArgName("factor");
    option.setRequired(false);
    option.setValueSeparator('=');
    options.addOption(option);

    option = new Option(null, CMD_OPT_NAME_IGNORERECORDSBEFOREDATE, true,
            "Records logged before this date (UTC timezone) are ignored (disabled by default).");
    option.setArgName(DATE_FORMAT_PATTERN_CMD_USAGE_HELP);
    option.setRequired(false);
    options.addOption(option);

    option = new Option(null, CMD_OPT_NAME_IGNORERECORDSAFTERDATE, true,
            "Records logged after this date (UTC timezone) are ignored (disabled by default).");
    option.setArgName(DATE_FORMAT_PATTERN_CMD_USAGE_HELP);
    option.setRequired(false);
    options.addOption(option);
}