Author: bayard
Date: Fri Feb 27 09:34:11 2009
New Revision: 748461

URL: http://svn.apache.org/viewvc?rev=748461&view=rev
Log:
Switching from the IllegalStateException to trying hard to work. A better user 
experience and didn't end up with the code being any more evil. CLI-162

Modified:
    
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
    
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java

Modified: 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java?rev=748461&r1=748460&r2=748461&view=diff
==============================================================================
--- 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/java/org/apache/commons/cli/HelpFormatter.java
 Fri Feb 27 09:34:11 2009
@@ -822,8 +822,7 @@
         if (nextLineTabStop >= width)
         {
             // stops infinite loop happening
-            throw new IllegalStateException("Total width is less than the 
width of the argument and indent " + 
-                                            "- no room for the description");
+            nextLineTabStop = width - 1;
         }
 
         // all following lines must be padded with nextLineTabStop space 

Modified: 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
URL: 
http://svn.apache.org/viewvc/commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java?rev=748461&r1=748460&r2=748461&view=diff
==============================================================================
--- 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 (original)
+++ 
commons/proper/cli/branches/cli-1.x/src/test/org/apache/commons/cli/bug/BugCLI162Test.java
 Fri Feb 27 09:34:11 2009
@@ -259,14 +259,44 @@
                           "                      yes.\n" +
                           "Footer\n";
         assertEquals( "Long arguments did not split as expected", expected, 
sw.toString() );
+    }
 
-        try {
-            formatter.printHelp(new PrintWriter(sw), 22, 
this.getClass().getName(), "Header", options, 0, 5, "Footer");
-            fail("IllegalStateException expected");
-        } catch(IllegalStateException ise) {
-            // expected
-        }
-
+    public void testLongLineChunkingIndentIgnored() throws ParseException, 
IOException {
+        Options options = new Options();
+        options.addOption("x", "extralongarg", false, "This description is 
Long." );
+        HelpFormatter formatter = new HelpFormatter();
+        StringWriter sw = new StringWriter();
+        formatter.printHelp(new PrintWriter(sw), 22, 
this.getClass().getName(), "Header", options, 0, 5, "Footer");
+        String expected = "usage:\n" +
+                          "       org.apache.comm\n" +
+                          "       ons.cli.bug.Bug\n" +
+                          "       CLI162Test\n" +
+                          "Header\n" +
+                          "-x,--extralongarg\n" +
+                          "                     T\n" +
+                          "                     h\n" +
+                          "                     i\n" +
+                          "                     s\n" +
+                          "                     d\n" +
+                          "                     e\n" +
+                          "                     s\n" +
+                          "                     c\n" +
+                          "                     r\n" +
+                          "                     i\n" +
+                          "                     p\n" +
+                          "                     t\n" +
+                          "                     i\n" +
+                          "                     o\n" +
+                          "                     n\n" +
+                          "                     i\n" +
+                          "                     s\n" +
+                          "                     L\n" +
+                          "                     o\n" +
+                          "                     n\n" +
+                          "                     g\n" +
+                          "                     .\n" +
+                          "Footer\n";
+        assertEquals( "Long arguments did not split as expected", expected, 
sw.toString() );
     }
 
 }


Reply via email to