commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 13935] New: - Request that OptionGroup support setRequired()
Date Thu, 24 Oct 2002 15:41:59 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13935>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=13935

Request that OptionGroup support setRequired()

           Summary: Request that OptionGroup support setRequired()
           Product: Commons
           Version: Nightly Builds
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: CLI
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: me@joemcglynn.com


As described below, I would like to see OptionGroup support setRequired(),
meaning that one and only one of the Options in the OptionGroup must be
specified.  From a usage perspective this would look something like the following:

        // create discrete options, these are the main choices
        // for this program, exactly _ONE_ of these must be specified
        cmdLineOpts = new Options();
        OptionGroup mainOptions = new OptionGroup();
        Option generateAll =    new Option(OPTION_ALL,
                                           OPTION_ALL_LONG,
                                           false,
                                           OPTION_ALL_HELP);
        Option generateTarget = new Option(OPTION_TARGET,
                                           OPTION_TARGET_LONG,
                                           true,
                                           OPTION_TARGET_HELP);
        Option generateLocal =  new Option(OPTION_LOCALHOST,
                                           OPTION_LOCALHOST_LONG,
                                           false,
                                           OPTION_LOCALHOST_HELP);
        Option showHelp =       new Option(OPTION_HELP,
                                           OPTION_HELP_LONG,
                                           false,
                                           OPTION_HELP_HELP);
        // set up a group of mutually-exclusive command line options
        mainOptions.addOption(generateAll);
        mainOptions.addOption(generateTarget);
        mainOptions.addOption(generateLocal);
        mainOptions.addOption(showHelp);

        // The following is the enhancement
        mainOptions.setRequired();

        // build options for parsing cmd line
        cmdLineOpts.addOptionGroup(mainOptions);
        // etc...



> I have a command that has three mutually-exclusive options, of which 
> _one_ is required.  That is my command can:
>
> command -goleft
> command -goright
> command -gostraight
>
> But not:
> command
>
>
> How do I represent that one of these three options is required?  Seems 
> like there should be a setRequired() on OptionGroup...
>
> It also seems like there should be a hierarchy of options, that is 
> "goleft" can have opta, optb, optc, but "goright can only have optb.

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message