@@ -136,11 +136,6 @@ public class HelpFormatter
136136 * Defaults to case-insensitive alphabetical sorting by option key
137137 */
138138 protected Comparator optionComparator = new OptionComparator ();
139-
140- /**
141- * Flag to determine if we try to determine terminal width
142- */
143- private boolean autoWidth = false ;
144139
145140 /**
146141 * Sets the 'width'.
@@ -331,28 +326,6 @@ public void setOptionComparator(Comparator comparator)
331326 }
332327 }
333328
334- /**
335- * Sets the 'autoWidth'.
336- *
337- * @param flag the new value of 'autoWidth'
338- */
339- public void setAutoWidth (boolean flag )
340- {
341- this .autoWidth = flag ;
342- int newWidth = (flag ? getTerminalWidth () : DEFAULT_WIDTH );
343- setWidth (newWidth );
344- }
345-
346- /**
347- * Returns the 'autoWidth'.
348- *
349- * @return the 'autoWidth'
350- */
351- public boolean getAutoWidth ()
352- {
353- return autoWidth ;
354- }
355-
356329 /**
357330 * Print the help for <code>options</code> with the specified
358331 * command line syntax. This method prints help information to
@@ -662,58 +635,6 @@ private static void appendOption(final StringBuffer buff, final Option option, f
662635 buff .append ("]" );
663636 }
664637 }
665-
666- /**
667- * Returns the auto-detected Terminal width as reported by stty -a
668- *
669- */
670-
671- private static int getTerminalWidth ()
672- {
673- int ret = DEFAULT_WIDTH ;
674- if (System .getProperty ("os.name" ).toLowerCase ().indexOf ("windows" ) == -1 ) {
675- String sttya = unixCmdOut ("stty -a < /dev/tty" );
676- StringTokenizer stok = new StringTokenizer (sttya , ";" );
677- while (stok .hasMoreTokens ()) {
678- String out = stok .nextToken ().trim ();
679- if (out .startsWith ("columns" )) {
680- int index = out .lastIndexOf (" " );
681- ret = Integer .parseInt (out .substring (index ).trim ());
682- break ;
683- } else if (out .endsWith ("columns" )) {
684- int index = out .indexOf (" " );
685- ret = Integer .parseInt (out .substring (0 , index ).trim ());
686- break ;
687- }
688- }
689- }
690- return ret ;
691- }
692-
693- /**
694- * Runs the provided Unix command line and returns stdout
695- *
696- * @param program the program to run
697- */
698- private static String unixCmdOut (String program )
699- {
700- int c ;
701- InputStream in ;
702- String rstr ;
703- ByteArrayOutputStream sout = new ByteArrayOutputStream ();
704- try {
705- Process p = Runtime .getRuntime ().exec (new String [] {"/bin/sh" ,"-c" ,program });
706- in = p .getInputStream ();
707- while ((c = in .read ()) != -1 ) {
708- sout .write (c );
709- }
710- p .waitFor ();
711- rstr = new String (sout .toString ());
712- } catch (Exception e ) {
713- rstr = new String (DEFAULT_WIDTH + " columns;" );
714- }
715- return rstr ;
716- }
717638
718639 /**
719640 * Print the cmdLineSyntax to the specified writer, using the
0 commit comments