Example usage for org.apache.commons.cli OptionBuilder hasArg

List of usage examples for org.apache.commons.cli OptionBuilder hasArg

Introduction

In this page you can find the example usage for org.apache.commons.cli OptionBuilder hasArg.

Prototype

public static OptionBuilder hasArg() 

Source Link

Document

The next Option created will require an argument value.

Usage

From source file:org.marketcetera.ors.security.ORSAdminCLI.java

/**
 * Returns the options accepted by the CLI.
 *
 * @return the options accepted by the CLI
 *//*  w w  w. ja va  2s .c o m*/
private static Options options() {
    Options opts = new Options();
    opts.addOption(OptionBuilder.hasArg().withArgName(CLI_ARG_LOGIN_VALUE.getText())
            .withDescription(CLI_PARM_USER.getText()).isRequired(true).create(OPT_CURRENT_USER));
    opts.addOption(OptionBuilder.hasArg().withArgName(CLI_ARG_LOGIN_PASSWORD_VALUE.getText())
            .withDescription(CLI_PARM_PASSWORD.getText()).isRequired(false).create(OPT_CURRENT_PASSWORD));

    OptionGroup commands = new OptionGroup();
    commands.setRequired(true);
    commands.addOption(OptionBuilder.withLongOpt(CMD_LIST_USERS).withDescription(CLI_CMD_LIST_USERS.getText())
            .isRequired().create());
    commands.addOption(OptionBuilder.withLongOpt(CMD_ADD_USER).withDescription(CLI_CMD_ADD_USER.getText())
            .isRequired().create());
    commands.addOption(OptionBuilder.withLongOpt(CMD_DELETE_USER).withDescription(CLI_CMD_DELETE_USER.getText())
            .isRequired().create());
    commands.addOption(OptionBuilder.withLongOpt(CMD_RESTORE_USER)
            .withDescription(CLI_CMD_RESTORE_USER.getText()).isRequired().create());
    commands.addOption(OptionBuilder.withLongOpt(CMD_CHANGE_PASS)
            .withDescription(CLI_CMD_CHANGE_PASSWORD.getText()).isRequired().create());
    commands.addOption(OptionBuilder.withLongOpt(CMD_CHANGE_SUPERUSER)
            .withDescription(CLI_CMD_CHANGE_SUPERUSER.getText()).isRequired().create());
    opts.addOptionGroup(commands);
    //Add optional arguments
    opts.addOption(OptionBuilder.withLongOpt("username"). //$NON-NLS-1$
            hasArg().withArgName(CLI_ARG_USER_NAME_VALUE.getText()).withDescription(CLI_PARM_OP_USER.getText())
            .isRequired(false).create(OPT_OPERATED_USER));
    opts.addOption(OptionBuilder.withLongOpt("password"). //$NON-NLS-1$
            hasArg().withArgName(CLI_ARG_USER_PASSWORD_VALUE.getText())
            .withDescription(CLI_PARM_OP_PASSWORD.getText()).isRequired(false).create(OPT_OPERATED_PASSWORD));
    opts.addOption(OptionBuilder.withLongOpt("superuser"). //$NON-NLS-1$
            hasArg().withArgName(CLI_ARG_USER_SUPERUSER_VALUE.getText())
            .withDescription(CLI_PARM_OP_SUPERUSER.getText()).isRequired(false).create(OPT_OPERATED_SUPERUSER));
    opts.addOption(OptionBuilder.withLongOpt("active"). //$NON-NLS-1$
            hasArg().withArgName(CLI_ARG_USER_ACTIVE_VALUE.getText())
            .withDescription(CLI_PARM_OP_ACTIVE.getText()).isRequired(false).create(OPT_OPERATED_ACTIVE));
    return opts;
}

From source file:org.midonet.midolman.tools.MmCtl.java

private static OptionGroup getOptionalOptionGroup() {
    OptionGroup optionalGroup = new OptionGroup();

    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt("config");
    OptionBuilder.withDescription("MM configuration file");
    optionalGroup.addOption(OptionBuilder.create());

    optionalGroup.setRequired(false);/*from www .  ja  v  a2  s .co m*/
    return optionalGroup;
}

From source file:org.midonet.midolman.tools.MmCtl.java

private static OptionGroup getMutuallyExclusiveOptionGroup() {

    // The command line tool can only accept one of these options:
    OptionGroup mutuallyExclusiveOptions = new OptionGroup();

    OptionBuilder.hasArgs(2);//ww  w.  j av a  2s . c om
    OptionBuilder.isRequired();
    OptionBuilder.withLongOpt("bind-port");
    OptionBuilder.withDescription("Bind a port to an interface");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.hasArg();
    OptionBuilder.isRequired();
    OptionBuilder.withLongOpt("unbind-port");
    OptionBuilder.withDescription("Unbind a port from an interface");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.withLongOpt("list-hosts");
    OptionBuilder.withDescription("List MidolMan agents in the system");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    // make sure that there is at least one.
    mutuallyExclusiveOptions.setRequired(true);

    return mutuallyExclusiveOptions;
}

From source file:org.midonet.mmdpctl.Mmdpctl.java

public static void main(String... args) {
    Options options = new Options();

    // The command line tool can only accept one of these options:
    OptionGroup mutuallyExclusiveOptions = new OptionGroup();

    OptionBuilder.withDescription("List all the installed datapaths");
    OptionBuilder.isRequired();//from w w  w.  j a  va 2  s  .  c o m
    OptionBuilder.withLongOpt("list-dps");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.withDescription("Show all the information related to a given datapath.");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired();
    OptionBuilder.withLongOpt("show-dp");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.withDescription("Show all the flows installed for a given datapath.");
    OptionBuilder.hasArg();
    OptionBuilder.isRequired();
    OptionBuilder.withLongOpt("dump-dp");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.withDescription("Add a new datapath.");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt("add-dp");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    OptionBuilder.withDescription("Delete a datapath.");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt("delete-dp");
    mutuallyExclusiveOptions.addOption(OptionBuilder.create());

    // make sure that there is at least one.
    mutuallyExclusiveOptions.setRequired(true);
    options.addOptionGroup(mutuallyExclusiveOptions);

    // add an optional timeout to the command.
    OptionBuilder.withDescription(
            "Specifies a timeout in seconds. " + "If the program is not able to get the results in less than "
                    + "this amount of time it will stop and return with an error code");
    OptionBuilder.hasArg();
    OptionBuilder.withLongOpt("timeout");
    options.addOption(OptionBuilder.create());

    CommandLineParser parser = new PosixParser();
    try {
        CommandLine cl = parser.parse(options, args);

        Mmdpctl mmdpctl = new Mmdpctl();

        // check if the user sets a (correct) timeout.
        if (cl.hasOption("timeout")) {
            String timeoutString = cl.getOptionValue("timeout");
            Integer timeout = Integer.parseInt(timeoutString);
            if (timeout > 0) {
                log.info("Installing a timeout of {} seconds", timeout);
                mmdpctl.setTimeout(timeout);
            } else {
                System.out.println("The timeout needs to be a positive number, bigger than 0.");
                System.exit(1);
            }
        }

        if (cl.hasOption("list-dps")) {
            System.exit(mmdpctl.execute(new ListDatapathsCommand()));
        } else if (cl.hasOption("show-dp")) {
            System.exit(mmdpctl.execute(new GetDatapathCommand(cl.getOptionValue("show-dp"))));
        } else if (cl.hasOption("dump-dp")) {
            System.exit(mmdpctl.execute(new DumpDatapathCommand(cl.getOptionValue("dump-dp"))));
        } else if (cl.hasOption("add-dp")) {
            System.exit(mmdpctl.execute(new AddDatapathCommand(cl.getOptionValue("add-dp"))));
        } else if (cl.hasOption("delete-dp")) {
            System.exit(mmdpctl.execute(new DeleteDatapathCommand(cl.getOptionValue("delete-dp"))));
        }

    } catch (ParseException e) {
        showHelpAndExit(options, e.getMessage());
    }

    System.exit(0);
}

From source file:org.mitre.scap.xccdf.XCCDFInterpreter.java

/**
 * @param args the command line arguments
 *//*  w  w w. j  a  va  2  s . com*/
public static void main(String[] args) throws IOException, XmlException, URISyntaxException {
    XCCDFInterpreter.generateExecutionTimeStr();
    BuildProperties buildProperties = BuildProperties.getInstance();

    //System.out.println();
    //System.out.println( buildProperties.getApplicationName()+" v"+ buildProperties.getApplicationVersion()+" build "+buildProperties.getApplicationBuild());
    //System.out.println("--------------------");
    //outputOsProperties();
    //System.out.println("--------------------");
    //System.out.println();

    // Define the commandline options
    @SuppressWarnings("static-access")
    Option help = OptionBuilder.withDescription("display usage").withLongOpt("help").create('h');

    @SuppressWarnings("static-access")
    Option workingDir = OptionBuilder.hasArg().withArgName("FILE").withDescription("use result directory FILE")
            .withLongOpt("result-dir").create('R');

    @SuppressWarnings("static-access")
    Option xccdfResultFilename = OptionBuilder.hasArg().withArgName("FILENAME")
            .withDescription("use result filename FILENAME").withLongOpt("xccdf-result-filename").create("F");

    @SuppressWarnings("static-access")
    Option nocpe = OptionBuilder.withDescription("do not process CPE references").withLongOpt("no-cpe")
            .create();

    @SuppressWarnings("static-access")
    Option noresults = OptionBuilder.withDescription("do not display rule results").withLongOpt("no-results")
            .create();

    @SuppressWarnings("static-access")
    Option nocheck = OptionBuilder.withDescription("do not process checks").withLongOpt("no-check").create();

    @SuppressWarnings("static-access")
    Option profile = OptionBuilder.hasArg().withArgName("PROFILE").withDescription("use given profile id")
            .withLongOpt("profile-id").create('P');

    @SuppressWarnings("static-access")
    Option ssValidation = OptionBuilder.hasArg().withArgName("SS-VALIDATION")
            .withDescription("use given validation id").withLongOpt("ssValidation-id").create("S");

    @SuppressWarnings("static-access")
    Option cpeDictionary = OptionBuilder.hasArg().withArgName("FILE")
            .withDescription("use given CPE 2.0 Dictionary file").withLongOpt("cpe-dictionary").create('C');

    @SuppressWarnings("static-access")
    Option cpeOVALDefinition = OptionBuilder.hasArg().withArgName("FILE")
            .withDescription("use given CPE OVAL definition file for CPE evaluation").withLongOpt("cpe-oval")
            .create('c');

    @SuppressWarnings("static-access")
    Option verbose = OptionBuilder.withDescription("produce verbose output").create("v");

    // Build the options list
    Options options = new Options();
    options.addOption(help);
    options.addOption(workingDir);
    options.addOption(xccdfResultFilename);
    options.addOption(profile);
    options.addOption(ssValidation);
    options.addOption(nocpe);
    options.addOption(noresults);
    options.addOption(nocheck);
    options.addOption(cpeDictionary);
    options.addOption(cpeOVALDefinition);
    options.addOption(verbose);

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

        String[] remainingArgs = line.getArgs();

        if (line.hasOption("help") || remainingArgs.length != 1) {
            if (remainingArgs.length != 1) {
                System.err.print("Invalid arguments: ");
                for (String arg : remainingArgs) {
                    System.err.print("'" + arg + "' ");
                }
                System.out.println();
            }

            // automatically generate the help statement
            System.out.println();
            showHelp(options);
            System.exit(0);
        }

        File xccdfFile = new File(remainingArgs[0]);

        if (!xccdfFile.exists()) {
            System.err.println(
                    "!! the specified XCCDF file '" + xccdfFile.getAbsolutePath() + "' does not exist!");
            System.exit(1);
        }

        XCCDFInterpreter interpreter = new XCCDFInterpreter(xccdfFile.getCanonicalFile());

        //System.out.println("** validating XCCDF content");

        if (!interpreter.validate()) {
            System.err.println("!! the XCCDF document is invalid. aborting.");
            System.exit(8);
        }

        if (line.hasOption(verbose.getOpt())) {
            verboseOutput = true;
            interpreter.setVerboseOutput(true);
        }

        if (line.hasOption(workingDir.getOpt())) {
            String lineOpt = line.getOptionValue(workingDir.getOpt());
            String workingDirValue = (lineOpt == null) ? "" : lineOpt;

            File f = new File(workingDirValue);
            if (!f.exists()) {
                if (verboseOutput)
                    System.out.println("** creating directory: " + f.getAbsolutePath());
                if (!f.mkdirs()) {
                    System.err.println("!! unable to create the result directory: " + f.getAbsolutePath());
                    System.exit(2);
                }
            }

            if (!f.isDirectory()) {
                System.err.println("!! the path specified for the result directory is not a directory: "
                        + f.getAbsolutePath());
                System.exit(3);
            }

            if (!f.canWrite()) {
                System.err.println("!! the path specified for the result directory is not writable: "
                        + f.getAbsolutePath());
                System.exit(4);
            }
            interpreter.setResultDirectory(f);
        }

        if (line.hasOption(xccdfResultFilename.getOpt())) {
            interpreter.setXccdfResultsFilename(line.getOptionValue(xccdfResultFilename.getOpt()));
        }

        if (line.hasOption(profile.getOpt())) {
            interpreter.setProfileId(line.getOptionValue(profile.getOpt()));
        }

        if (line.hasOption(ssValidation.getOpt())) {
            interpreter.setssValidationId(line.getOptionValue(ssValidation.getOpt()));
        }

        if (line.hasOption(nocpe.getLongOpt())) {
            interpreter.setProcessCPE(false);
        }

        if (line.hasOption(noresults.getLongOpt())) {
            interpreter.setDisplayResults(false);
        }

        if (line.hasOption(nocheck.getLongOpt())) {
            interpreter.setProcessChecks(false);
        }

        if (interpreter.processCPE == true) {

            if (line.hasOption(cpeDictionary.getOpt())) {
                String lineOpt = line.getOptionValue(cpeDictionary.getOpt());
                String cpeDict = (lineOpt == null) ? "" : lineOpt;

                File f = new File(cpeDict);

                if (!f.exists()) {
                    System.err.println("The CPE dictionary file does not exist: " + f.getAbsolutePath());
                    System.exit(5);
                }

                if (!f.isFile()) {
                    System.err.println("The path specified for the CPE dictionary file is not a file: "
                            + f.getAbsolutePath());
                    System.exit(6);
                }

                if (!f.canRead()) {
                    System.err.println("The path specified for the CPE dictionary file is not readable: "
                            + f.getAbsolutePath());
                    System.exit(7);
                }
                interpreter.setCPEDictionaryFile(f);
            }

            if (line.hasOption(cpeOVALDefinition.getOpt())) {
                String lineOpt = line.getOptionValue(cpeOVALDefinition.getOpt());
                String cpeOVAL = (lineOpt == null) ? "" : lineOpt;

                File f = new File(cpeOVAL);

                if (!f.exists()) {
                    System.err.println(
                            "!! the CPE OVAL inventory definition file does not exist: " + f.getAbsolutePath());
                    System.exit(5);
                }

                if (!f.isFile()) {
                    System.err.println(
                            "!! the path specified for the CPE OVAL inventory definition file is not a file: "
                                    + f.getAbsolutePath());
                    System.exit(6);
                }

                if (!f.canRead()) {
                    System.err.println(
                            "!! the path specified for the CPE OVAL inventory definition file is not readable: "
                                    + f.getAbsolutePath());
                    System.exit(7);
                }
                interpreter.setCPEOVALDefinitionFile(f);
            }

        } // END IF processCPE

        interpreter.process();

    } catch (ParseException ex) {
        System.err.println("!! parsing failed : " + ex.getMessage());
        System.out.println();
        showHelp(options);
    } catch (ProfileNotFoundException ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (CircularReferenceException ex) {
        System.err.println("!! checklist processing failed : " + ex.getMessage());
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (ExtensionScopeException ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (ItemNotFoundException ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (PropertyNotFoundException ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (CPEEvaluationException ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    } catch (Exception ex) {
        if (verboseOutput == true)
            ex.printStackTrace();
        else
            System.err.println("!! checklist processing failed : " + ex.getMessage());
    }

}

From source file:org.movsim.input.MovsimCommandLine.java

private void createOptions() {
    options = new Options();
    options.addOption("h", "help", false, "prints this message");
    options.addOption("v", "validate", false, "parses xml input file for validation (without simulation)");
    options.addOption("w", "write_xsd", false,
            "writes xsd file to output (for convenience/lookup schema definitions)");
    options.addOption("l", "log", false,
            "writes the file \"log4j.properties\" to file to adjust the logging properties on an individual level");
    options.addOption("d", "write_dot", false, "writes a 'dot' network file for further analysis of the xodr");
    options.addOption("s", "simulation scanning mode", false,
            "invokes the simulator repeatedly in a loop (needs to be programmed by user)");

    OptionBuilder.withArgName("file");
    OptionBuilder.hasArg();
    ProjectMetaData.getInstance();// ww  w .j  a  va 2  s .c  om
    OptionBuilder.withDescription("movsim main configuration file (ending \""
            + ProjectMetaData.getMovsimConfigFileEnding() + "\" will be added automatically if not provided.");
    final Option xmlSimFile = OptionBuilder.create("f");
    options.addOption(xmlSimFile);

    OptionBuilder.withArgName("directory");
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("argument is the output path relative to calling directory");
    final Option outputPathOption = OptionBuilder.create("o");
    options.addOption(outputPathOption);
}

From source file:org.nuxeo.launcher.NuxeoLauncher.java

/**
 * @since 5.6//from  w w w  .  j  a va 2s.  c o m
 */
protected static void initParserOptions() {
    if (launcherOptions == null) {
        launcherOptions = new Options();
        // help option
        OptionBuilder.withLongOpt(OPTION_HELP);
        OptionBuilder.withDescription(OPTION_HELP_DESC);
        launcherOptions.addOption(OptionBuilder.create("h"));
        // Quiet option
        OptionBuilder.withLongOpt(OPTION_QUIET);
        OptionBuilder.withDescription(OPTION_QUIET_DESC);
        launcherOptions.addOption(OptionBuilder.create("q"));
        // Debug option
        OptionBuilder.withLongOpt(OPTION_DEBUG);
        OptionBuilder.withDescription(OPTION_DEBUG_DESC);
        launcherOptions.addOption(OptionBuilder.create("d"));
        // Debug category option
        OptionBuilder.withDescription(OPTION_DEBUG_CATEGORY_DESC);
        OptionBuilder.hasArg();
        launcherOptions.addOption(OptionBuilder.create(OPTION_DEBUG_CATEGORY));
        OptionGroup outputOptions = new OptionGroup();
        // Hide deprecation warnings option
        OptionBuilder.withLongOpt(OPTION_HIDE_DEPRECATION);
        OptionBuilder.withDescription(OPTION_HIDE_DEPRECATION_DESC);
        outputOptions.addOption(OptionBuilder.create());
        // XML option
        OptionBuilder.withLongOpt(OPTION_XML);
        OptionBuilder.withDescription(OPTION_XML_DESC);
        outputOptions.addOption(OptionBuilder.create());
        // JSON option
        OptionBuilder.withLongOpt(OPTION_JSON);
        OptionBuilder.withDescription(OPTION_JSON_DESC);
        outputOptions.addOption(OptionBuilder.create());
        launcherOptions.addOptionGroup(outputOptions);
        // GUI option
        OptionBuilder.withLongOpt(OPTION_GUI);
        OptionBuilder.hasArg();
        OptionBuilder.withArgName("true|false");
        OptionBuilder.withDescription(OPTION_GUI_DESC);
        launcherOptions.addOption(OptionBuilder.create());
        // Package management option
        OptionBuilder.withLongOpt(OPTION_NODEPS);
        OptionBuilder.withDescription(OPTION_NODEPS_DESC);
        launcherOptions.addOption(OptionBuilder.create());
        // Relax on target platform option
        OptionBuilder.withLongOpt(OPTION_RELAX);
        OptionBuilder.hasArg();
        OptionBuilder.withArgName("true|false|ask");
        OptionBuilder.withDescription(OPTION_RELAX_DESC);
        launcherOptions.addOption(OptionBuilder.create());
        // Accept option
        OptionBuilder.withLongOpt(OPTION_ACCEPT);
        OptionBuilder.hasArg();
        OptionBuilder.withArgName("true|false|ask");
        OptionBuilder.withDescription(OPTION_ACCEPT_DESC);
        launcherOptions.addOption(OptionBuilder.create());
    }
}

From source file:org.openmainframe.ade.ext.main.Analyze.java

/**
 * Method to parse specific arguments for "Analyze".
 *///from   ww w  .j a  v  a 2 s.c  o m
@Override
protected final void parseArgs(String[] args) throws AdeException {
    final Options options = new Options();

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.isRequired(false);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("Specify the Source to be analyzed.  ");
    options.addOption(OptionBuilder.create("s"));

    super.parseArgs(options, args);

}

From source file:org.openmainframe.ade.ext.main.helper.AdeExtOptions.java

public static Options buildOptions(Options subClassOptions) {
    /* Add the options from subClass */
    Options options = new Options();
    for (Object subClassOption : subClassOptions.getOptions()) {
        Option option = (Option) subClassOption;
        options.addOption(option);//from w  w  w  .  j  a  va  2  s.  co m
    }

    /* Add the general options */
    OptionBuilder.withArgName(OPTION_HELP);
    OptionBuilder.withLongOpt(OPTION_HELP);
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Print help message and exit");
    options.addOption(OptionBuilder.create('h'));

    OptionBuilder.withArgName(OPTION_INPUT_FILE);
    OptionBuilder.withLongOpt(OPTION_INPUT_FILE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input file name or 'stdin'");
    options.addOption(OptionBuilder.create('f'));

    OptionBuilder.withArgName(OPTION_INPUT_DIR);
    OptionBuilder.withLongOpt(OPTION_INPUT_DIR);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Input dir name");
    options.addOption(OptionBuilder.create('d'));

    OptionBuilder.withArgName(OPTION_SOURCES);
    OptionBuilder.withLongOpt(OPTION_SOURCES);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("Source Names.");
    options.addOption(OptionBuilder.create('s'));

    OptionBuilder.withArgName(OPTION_OS_TYPE);
    OptionBuilder.withLongOpt(OPTION_OS_TYPE);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("The OS Type." + "If this option is omitted, the default is Linux");
    options.addOption(OptionBuilder.create('o'));

    OptionBuilder.withArgName(OPTION_GMT_OFFSET);
    OptionBuilder.withLongOpt(OPTION_GMT_OFFSET);
    OptionBuilder.hasArg();
    OptionBuilder.isRequired(false);
    OptionBuilder.withDescription("hours offset from GMT");
    options.addOption(OptionBuilder.create('g'));

    return options;
}

From source file:org.openmainframe.ade.ext.main.helper.LinuxOptions.java

@Override
public void addPlatformSpecificOptions(Options options) {
    OptionBuilder.withArgName(OPTION_YEAR);
    OptionBuilder.hasArg();
    OptionBuilder.withDescription("year of messages in Linux syslogs");
    options.addOption(OptionBuilder.create(OPTION_YEAR));
}