Skip to content

Commit 4dcbfa6

Browse files
author
John Keyes
committed
now supports new Option i.e. key changed from char to String
git-svn-id: https://svn.apache.org/repos/asf/jakarta/commons/proper/cli/trunk@129783 13f79535-47bb-0310-9956-ffa450edef68
1 parent 7e3bcff commit 4dcbfa6

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

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

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
* A formatter of help messages for the current command line options
7373
*
7474
* @author Slawek Zachcial
75+
* @author John Keyes (jbjk at mac.com)
7576
**/
7677
public class HelpFormatter
7778
{
@@ -244,14 +245,21 @@ protected StringBuffer renderOptions( StringBuffer sb,
244245

245246
//finally render options
246247
int nextLineTabStop = max + descPad;
247-
char opt;
248+
String opt;
248249
int optOffset = leftPad + defaultOptPrefix.length();
249250

250251
for ( Iterator i = prefixList.iterator(); i.hasNext(); )
251252
{
252253
optBuf = (StringBuffer) i.next();
253-
opt = optBuf.charAt(optOffset);
254-
option = options.getOption( "" + opt);
254+
opt = optBuf.toString();
255+
if( opt.indexOf( ',' ) != -1 ) {
256+
opt = opt.substring( optOffset, opt.indexOf( ',', optOffset ) );
257+
}
258+
else {
259+
opt = opt.substring( optOffset, opt.indexOf( ' ', optOffset ) );
260+
}
261+
option = options.getOption( "-" + opt );
262+
255263
renderWrappedText(sb, width, nextLineTabStop,
256264
optBuf.append(option.getDescription()).toString());
257265
if ( i.hasNext() )

0 commit comments

Comments
 (0)