jkeyes 2002/11/15 14:22:47
Modified: cli/src/java/org/apache/commons/cli HelpFormatter.java
Log:
some fixes to avoid 'null' appearing in the help output
Revision Changes Path
1.10 +7 -7
jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java
Index: HelpFormatter.java
===================================================================
RCS file:
/home/cvs/jakarta-commons/cli/src/java/org/apache/commons/cli/HelpFormatter.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- HelpFormatter.java 11 Oct 2002 23:10:40 -0000 1.9
+++ HelpFormatter.java 15 Nov 2002 22:22:47 -0000 1.10
@@ -277,13 +277,9 @@
buff.append( "--" ).append( option.getLongOpt() );
}
- if( option.hasArg() ){
- buff.append( " " );
- }
-
// if the Option has a value
- if( option.hasArg() ) {
- buff.append( option.getArgName() );
+ if( option.hasArg() && option.getArgName() != null ) {
+ buff.append( " " ).append( option.getArgName() );
}
// if the Option is not a required option
@@ -389,8 +385,12 @@
optBuf.append( dpad );
int nextLineTabStop = max + descPad;
+
+ if( option.getDescription() != null ) {
+ optBuf.append( option.getDescription() );
+ }
renderWrappedText(sb, width, nextLineTabStop,
- optBuf.append(option.getDescription()).toString());
+ optBuf.toString());
if ( i.hasNext() )
{
sb.append(defaultNewLine);
--
To unsubscribe, e-mail: <mailto:commons-dev-unsubscribe@;jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@;jakarta.apache.org>