You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2002/12/19 11:10:29 UTC
DO NOT REPLY [Bug 15521] New: -
Enhancement to the MissingOptionException class
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>