Uploaded image for project: 'Commons CLI'
  1. Commons CLI
  2. CLI-267

Add an addRequiredOption method to Options

    Details

    • Type: New Feature
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.4
    • Component/s: Options definition
    • Labels:

      Description

      Placeholder issue for https://github.com/apache/commons-cli/pull/7

      This pull request adds an addRequiredOption method, which creates an Option with setRequired(true).

      This is really useful, given the amount of projects I saw doing things like:

      Options options = new Options();
      options.addOption( "a", "all", false, "do not hide entries starting with ." );
      options.addOption( "A", "almost-all", false, "do not list implied . and .." );
      options.addOption( "b", "escape", false, "print octal escapes for nongraphic " + "characters" );
      // ... more addOptions like these and then
      Option stuff = new Option( "c", "stuff", true, "do not list implied . and .." );
      stuff.setRequired(true);
      options.addOption( stuff );
      // And many more required options like this one
      

      This pull request proposes an auxiliary method to create a required option, so that these options could just be added with.

      options.addRequiredOption( "c", "stuff", true, "do not list implied . and .." );
      

        Attachments

          Activity

            People

            • Assignee:
              britter Benedikt Ritter
              Reporter:
              britter Benedikt Ritter
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: