Skip to content

Commit 4c34483

Browse files
author
John Keyes
committed
some fixes to avoid 'null' appearing in the help output
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@129844 13f79535-47bb-0310-9956-ffa450edef68
1 parent 0c281fb commit 4c34483

1 file changed

Lines changed: 7 additions & 7 deletions

File tree

src/java/org/apache/commons/cli/HelpFormatter.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -277,13 +277,9 @@ public void printUsage( PrintWriter pw, int width, String app, Options options )
277277
buff.append( "--" ).append( option.getLongOpt() );
278278
}
279279

280-
if( option.hasArg() ){
281-
buff.append( " " );
282-
}
283-
284280
// if the Option has a value
285-
if( option.hasArg() ) {
286-
buff.append( option.getArgName() );
281+
if( option.hasArg() && option.getArgName() != null ) {
282+
buff.append( " " ).append( option.getArgName() );
287283
}
288284

289285
// if the Option is not a required option
@@ -389,8 +385,12 @@ protected StringBuffer renderOptions( StringBuffer sb,
389385
optBuf.append( dpad );
390386

391387
int nextLineTabStop = max + descPad;
388+
389+
if( option.getDescription() != null ) {
390+
optBuf.append( option.getDescription() );
391+
}
392392
renderWrappedText(sb, width, nextLineTabStop,
393-
optBuf.append(option.getDescription()).toString());
393+
optBuf.toString());
394394
if ( i.hasNext() )
395395
{
396396
sb.append(defaultNewLine);

0 commit comments

Comments
 (0)