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:net.sourceforge.dita4publishers.tools.mapreporter.MapBosReporter.java

/**
 * @return/*from  www  .ja v a  2  s . c o  m*/
 */
protected static Options configureOptions() {
    Options options = configureOptionsBase();
    Option opt = null;

    options.addOption(INPUT_OPTION_ONE_CHAR, "map", true,
            "(Input) The root map from which to calculate the map tree or bounded object set");
    opt = options.getOption(INPUT_OPTION_ONE_CHAR);
    opt.setRequired(true);

    options.addOption(OUTPUT_OPTION_ONE_CHAR, "out", true,
            "(Output) The name of the output directory and, optionally, report file to generate.  "
                    + "If not specified, output goes to STDOUT.");
    opt = options.getOption(OUTPUT_OPTION_ONE_CHAR);
    opt.setRequired(false);

    options.addOption(CATALOG_OPTION_ONE_CHAR, "catalog", true,
            "(Catalog) Path and filename of the XML catalog to use for resolving DTDs (e.g., catalog-dita.xml)");
    opt = options.getOption(OUTPUT_OPTION_ONE_CHAR);
    opt.setRequired(false);

    options.addOption(DITAVAL_OPTION_ONE_CHAR, "ditaval", true,
            "(Ditaval) Path and filename of the the Ditaval file to used to determine applicable key definitions and other elements.");
    opt = options.getOption(DITAVAL_OPTION_ONE_CHAR);
    opt.setRequired(false);

    options.addOption(BOS_REPORTER_CLASS_OPTION_ONE_CHAR, "bosreporterclass", true,
            "(BOS reporter class) Fully-qualified class name of the BOS reporter to use. "
                    + "If not specified, the built-in text BOS reporter is used.");
    opt = options.getOption(BOS_REPORTER_CLASS_OPTION_ONE_CHAR);
    opt.setRequired(false);

    options.addOption(KEYSPACE_REPORTER_CLASS_OPTION_ONE_CHAR, "keyspacereporterclass", true,
            "(Key space reporter class) Fully-qualified class name of the key space reporter to use."
                    + " If not specified, the built-in text key space reporter is used.");
    opt = options.getOption(KEYSPACE_REPORTER_CLASS_OPTION_ONE_CHAR);
    opt.setRequired(false);

    options.addOption(MAPTREE_OPTION_ONE_CHAR, "maptree", false,
            "(Map tree only) When specified, only calculates the map tree, not the entire DITA BOS.");
    opt = options.getOption(OUTPUT_OPTION_ONE_CHAR);
    opt.setRequired(false);

    return options;
}

From source file:com.opengamma.component.tool.AbstractDualComponentTool.java

private static Option createSourceComponentServerOption() {
    Option option = new Option(SRC_COMPONENT_SERVER_URI_OPTION, "source-component-server", true,
            "the source component server, host[:port]");
    option.setArgName("source component server");
    option.setRequired(true);
    return option;
}

From source file:neembuu.uploader.cmd.Main.java

private static void work(String[] args)
        throws InstantiationException, IllegalAccessException, ParseException, URISyntaxException {
    Options options = new Options();
    Option file = new Option("f", true, "File to upload.");
    file.setRequired(true);
    Option filehost = new Option("h", true, "Filehost domain");
    filehost.setRequired(true);/*from  www  . j  a  v a  2s.  c o m*/
    options.addOption(file);
    options.addOption(filehost);
    options.addOption("u", true, "Username");
    options.addOption("p", true, "Password");
    options.addOption("help", false, "Display help");

    String fileName = null, hostname = null, username = null, password = null;//,userName,password;
    if (args.length < 1) {
        System.out.println("syntax fileName hostname "
        //+ "userName password"
        );

        fileName = "F:\\tempimages\\20150802100655.jpg";
        hostname = "mediafire.com";
        //username = "shashaanktulsyan@gmail.com";
        //password = "";
        //"Solidfiles.com";
        //"4Shared.com";
        System.out.println("assuming for test purpose" + fileName + " and host " + hostname);
    } else {
        CommandLineParser parser = new DefaultParser();
        CommandLine cmd = parser.parse(options, args);
        if (cmd.hasOption("help") || args.length == 0) {
            HelpFormatter formatter = new HelpFormatter();
            formatter.printHelp("help", options);
            System.exit(0);
        } else {
            fileName = cmd.getOptionValue("f");
            hostname = cmd.getOptionValue("h"); //userName=args[2]; password=args[3];
            if (cmd.hasOption("u") && cmd.hasOption("p")) {
                username = cmd.getOptionValue("u");
                password = cmd.getOptionValue("p");
            }
        }
    }

    System.out.println("===Listing all active and non-active plugins===");
    for (SmallModuleEntry sme : pa.getAllPlugins()) {
        System.out.println(sme.getName());

    }
    System.out.println("===============================================");

    SmallModuleEntry sme = pa.getPluginByName(hostname);
    UploaderPlugin up = pa.activatePlugin(sme);

    Class<? extends Uploader> uClass = up
            .getUploader(DummyPluginDestructionListener.make(sme.getName() + "-uploader"));

    Class<? extends Account> aClass = up
            .getAccount(DummyPluginDestructionListener.make(sme.getName() + "-account"));

    Account a;// = aClass==null?null:aClass.newInstance();

    /*
     Call getAccounts twice because the first time is only registering the account into the manager and not returning the insance
     */
    //Account a = amw.getAccount(sme.getName());
    if (username != null && password != null) {
        a = amw.getAccount(sme.getName());

        Utils.init(hostname, a, username, password);
        a.setOverridingCredentials(username, password); // redundant
        a.login();
        System.out.println("account = " + a);

        if (!a.isLoginSuccessful()) {
            System.out.println("Login failed. Terminating.");
            System.exit(0);
        }
    }

    Uploader u = uClass.newInstance();

    u.setFile(new File(fileName));
    //u.startUpload();
    u.run(); // upload in same thread
    System.out.println("Delete URL=" + u.getDeleteURL());
    System.out.println("Download URL=" + u.getDownloadURL());

    System.exit(0);
}

From source file:com.bc.fiduceo.post.PostProcessingTool.java

static Options getOptions() {
    final Options options = new Options();

    final Option helpOption = new Option("h", "help", false, "Prints the tool usage.");
    options.addOption(helpOption);/*from  w  w w  .jav  a  2  s  . c o  m*/

    final Option configOption = new Option("c", "config", true,
            "Defines the configuration directory. Defaults to './config'.");
    options.addOption(configOption);

    final Option mmdDir = new Option("i", "input-dir", true,
            "Defines the path to the input mmd files directory.");
    mmdDir.setRequired(true);
    options.addOption(mmdDir);

    final Option ppuc = new Option("j", "job-config", true,
            "Defines the path to post processing job configuration file. Path is relative to the configuration directory.");
    ppuc.setRequired(true);
    options.addOption(ppuc);

    final Option startOption = new Option("start", "start-date", true,
            "Defines the processing start-date, format 'yyyy-DDD'. DDD = Day of year.");
    startOption.setRequired(true);
    options.addOption(startOption);

    final Option endOption = new Option("end", "end-date", true,
            "Defines the processing end-date, format 'yyyy-DDD'. DDD = Day of year.");
    endOption.setRequired(true);
    options.addOption(endOption);

    return options;
}

From source file:com.opengamma.component.tool.AbstractTool.java

private static Option createLogbackOption() {
    final Option option = new Option(LOGBACK_RESOURCE_OPTION, "logback", true,
            "the logback configuration resource");
    option.setArgName("resource");
    option.setRequired(false);
    return option;
}

From source file:com.opengamma.component.tool.AbstractDualComponentTool.java

private static Option createDestinationComponentServerOption() {
    Option option = new Option(DEST_COMPONENT_SERVER_URI_OPTION, "destination-component-server", true,
            "the destination component server, host[:port]");
    option.setArgName("source component server");
    option.setRequired(true);
    return option;
}

From source file:com.opengamma.component.tool.AbstractTool.java

private static Option createConfigOption(final boolean mandatoryConfigResource) {
    final Option option = new Option(CONFIG_RESOURCE_OPTION, "config", true,
            "the toolcontext configuration resource");
    option.setArgName("resource");
    option.setRequired(mandatoryConfigResource);
    return option;
}

From source file:de.uni_koblenz.jgralab.utilities.tgraphbrowser.TGraphBrowserServer.java

/**
 * Processes the command line options.//from   w  w w  . j a v  a  2  s. c om
 * 
 * @param args
 * @return
 */
private static CommandLine processCommandLineOptions(String[] args) {
    String toolString = "java " + TGraphBrowserServer.class.getName();
    String versionString = getInfo();
    OptionHandler oh = new OptionHandler(toolString, versionString);

    Option output = new Option("w", "workspace", true,
            "(optional): the workspace. Default is $temp$/tgraphbrowser/workspace");
    output.setRequired(false);
    output.setArgName("path");
    oh.addOption(output);

    Option stateTimeout = new Option("t", "state_timeout", true, "(optional): resources are freed, "
            + "if they were not used in the last <given> seconds." + " Default value is 600 sec.");
    stateTimeout.setRequired(false);
    stateTimeout.setArgName("sec");
    oh.addOption(stateTimeout);

    Option checkInterval = new Option("ci", "check_interval", true,
            "(optional): the interval in sec after which the states"
                    + " are checked, if thex are to old. Default value is 60 sec.");
    checkInterval.setRequired(false);
    checkInterval.setArgName("sec");
    oh.addOption(checkInterval);

    Option timeToCreateDot = new Option("td", "time_for_dot", true,
            "(optional): the interval in sec after which the execution of dot is aborted."
                    + " Default value is 60 sec.");
    timeToCreateDot.setRequired(false);
    timeToCreateDot.setArgName("sec");
    oh.addOption(timeToCreateDot);

    Option port = new Option("p", "port", true, "(optional): the port of the server. Default is port 8080.");
    port.setRequired(false);
    port.setArgName("portnumber");
    oh.addOption(port);

    Option incidences = new Option("i", "incidences", true,
            "(optional): number of incident edges which are" + " shown in the table view. Default is 10.");
    incidences.setRequired(false);
    incidences.setArgName("int");
    oh.addOption(incidences);

    Option dot = new Option("d", "dot", true,
            "(optional): the command to call dot." + " If it is not set, the 2D-view won't be available.");
    dot.setRequired(false);
    dot.setArgName("command");
    oh.addOption(dot);

    Option maxSize = new Option("m", "maximum_filesize", true,
            "(optional): the maximum size of a tg-file which is loaded in MB");
    maxSize.setRequired(false);
    maxSize.setArgName("int");
    oh.addOption(maxSize);

    Option size = new Option("s", "size_of_workspace", true,
            "(optional): the maximum size of the workspace in MB." + " Newly submitted tg.-files are rejected,"
                    + " if maximumSizeOfWorkspace < currentSizeOfWorkspace + sizeOfSubmittedTgFile ");
    size.setRequired(false);
    size.setArgName("int");
    oh.addOption(size);

    Option roleNames = new Option("r", "print-role-names", false,
            "(optional): Print role names in the 2D view.  Defaults to false.");
    roleNames.setRequired(false);
    oh.addOption(roleNames);

    return oh.parse(args);
}

From source file:ee.ria.xroad.opmonitordaemon.OperationalDataRecordsGenerator.java

private static Options getOptions() {
    Options options = new Options();

    Option firstTimestamp = new Option("t", "timestamp", true,
            "first timestamp (default: " + DEFAULT_FIRST_TIMESTAMP + "),"
                    + " every record in one batch has the same timestamp, for"
                    + " next batch timestamp is increased by 1");
    firstTimestamp.setRequired(false);
    options.addOption(firstTimestamp);//from   www . j  a v a2 s  .co m

    Option batchSize = new Option("s", "batch-size", true, "batch size (default: " + DEFAULT_BATCH_SIZE + ")");
    batchSize.setRequired(false);
    options.addOption(batchSize);

    Option batchCount = new Option("c", "batch-count", true,
            "batch count (default: " + DEFAULT_BATCH_COUNT + ")");
    batchCount.setRequired(false);
    options.addOption(batchCount);

    Option longStringLength = new Option("lsl", "long-string-length", true,
            "long string length (default: " + DEFAULT_LONG_STRING_LENGTH + ")");
    longStringLength.setRequired(false);
    options.addOption(longStringLength);

    Option shortStringLength = new Option("ssl", "short-string-length", true,
            "short string length (default: " + DEFAULT_SHORT_LONG_STRING_LENGTH + ")");
    shortStringLength.setRequired(false);
    options.addOption(shortStringLength);

    Option usage = new Option("h", "help", false, "help");
    usage.setRequired(false);
    options.addOption(usage);

    return options;
}

From source file:fr.inria.atlanmod.emf.graphs.Connectedness.java

/**
 * Creates the program options//from   w  w w  .  j  a va  2 s  .  c  om
 * 
 * @param options
 * @return
 */
private static Options createOptions() {

    Options options = new Options();

    Option inputMetamodelOpt = OptionBuilder.create(INPUT_METAMODEL);
    inputMetamodelOpt.setLongOpt(INPUT_METAMODEL_LONG);
    inputMetamodelOpt.setArgName("source.ecore");
    inputMetamodelOpt.setDescription("Path of the source metamodel file");
    inputMetamodelOpt.setArgs(1);
    inputMetamodelOpt.setRequired(true);

    Option inputModelOpt = OptionBuilder.create(INPUT_MODEL);
    inputModelOpt.setLongOpt(INPUT_MODEL_LONG);
    inputModelOpt.setArgName("input.xmi");
    inputModelOpt.setDescription("Path of the input file");
    inputModelOpt.setArgs(1);
    inputModelOpt.setRequired(true);

    Option logUnreachableOpt = OptionBuilder.create(LOG_UNREACHABLE);
    logUnreachableOpt.setLongOpt(LOG_UNREACHABLE_LONG);
    logUnreachableOpt.setDescription("Log information about unreachable objects");
    logUnreachableOpt.setArgs(0);
    logUnreachableOpt.setRequired(false);

    options.addOption(inputMetamodelOpt);
    options.addOption(inputModelOpt);
    options.addOption(logUnreachableOpt);

    return options;
}