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 15521] New: - Enhancement to the MissingOptionException class
Date Thu, 19 Dec 2002 10:10:29 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=15521>.
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=15521

Enhancement to the MissingOptionException class

           Summary: Enhancement to the MissingOptionException class
           Product: Commons
           Version: 1.0 Beta 1
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: CLI
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: trygvela@ifi.uio.no


Hi!

When doing something like this: 

        try {
            line = parser.parse(options, args);
        }
        catch(MissingOptionException ex) {
            System.err.println("Missing option: " + ex.getMessage());
            return;
        }

And I have a coulple of required options in the options set I will get this 
output:

Missing option: -contextfactory-url-username-password

Since this is not a good way to inform the users about the missing options I 
would suggest to do something like this in Parser.checkRequiredOptions():

MissingOptionException ex = new MissingOptionException();

void checkRequiredOptions() {
  if( requiredOptions.size() > 0 ) {
    Iterator iter = requiredOptions.iterator();
    StringBuffer buff = new StringBuffer();

    // loop through the required options
    while( iter.hasNext() ) {
        String str = (String)iter.next();
        buff.append(str + " ");
        ex.addMissingOption(str);
    }
    
    throw ex;
}

The MissingOptionException implementation will need to be changed. This will 
enable me to give a nicely formatted output if I want to, while still 
retaining the current implementation.

If you would like I can create and submit a patch for this.

Regards, Trygve Laugstøl

--
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