commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jke...@apache.org
Subject cvs commit: jakarta-commons/cli/src/java/org/apache/commons/cli HelpFormatter.java
Date Fri, 11 Oct 2002 23:10:40 GMT
jkeyes      2002/10/11 16:10:40

  Modified:    cli/src/java/org/apache/commons/cli HelpFormatter.java
  Log:
  some fixes for autousage and padding
  
  Revision  Changes    Path
  1.9       +12 -9     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.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- HelpFormatter.java	8 Oct 2002 21:24:11 -0000	1.8
  +++ HelpFormatter.java	11 Oct 2002 23:10:40 -0000	1.9
  @@ -79,7 +79,7 @@
   {
      // --------------------------------------------------------------- Constants
   
  -   public static final int DEFAULT_WIDTH              = 80;
  +   public static final int DEFAULT_WIDTH              = 74;
      public static final int DEFAULT_LEFT_PAD           = 1;
      public static final int DEFAULT_DESC_PAD           = 3;
      public static final String DEFAULT_SYNTAX_PREFIX   = "usage: ";
  @@ -277,10 +277,7 @@
                      buff.append( "--" ).append( option.getLongOpt() );
                  }
   
  -               if( option.getValueSeparator() != (char)0 ) {
  -                   buff.append( option.getValueSeparator() );
  -               }
  -               else if( option.hasArg() ){
  +               if( option.hasArg() ){
                      buff.append( " " );
                  }
   
  @@ -347,7 +344,7 @@
         List prefixList = new ArrayList();
         Option option;
         List optList = options.helpOptions();
  -       Collections.sort( optList, new StringBufferComparator() );
  +      Collections.sort( optList, new StringBufferComparator() );
         for ( Iterator i = optList.iterator(); i.hasNext(); )
         {
            option = (Option) i.next();
  @@ -369,7 +366,7 @@
   
            if( option.hasArg() ) {
                if( option.hasArgName() ) {
  -                 optBuf.append( option.getArgName() );
  +                 optBuf.append(" <").append( option.getArgName() ).append( '>' );
                }
                else {
                    optBuf.append(' ');
  @@ -378,12 +375,18 @@
   
            prefixList.add(optBuf);
            max = optBuf.length() > max ? optBuf.length() : max;
  +      }
  +      int x = 0;
  +      for ( Iterator i = optList.iterator(); i.hasNext(); )
  +      {
  +         option = (Option) i.next();
  +         optBuf = new StringBuffer( prefixList.get( x++ ).toString() );
   
            if ( optBuf.length() < max )
            {
  -             optBuf.append(createPadding(max-optBuf.length()));
  +             optBuf.append(createPadding(max - optBuf.length()));
            }
  -         optBuf.append(dpad);
  +         optBuf.append( dpad );
            
            int nextLineTabStop = max + descPad;
            renderWrappedText(sb, width, nextLineTabStop,
  
  
  

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