Package Apache.CLI



Class HelpFormatter


  • public class HelpFormatter
    extends java.lang.Object
    This Class-File has been copied, directly from the Apache Commons Software Foundation. Other than the minor, cosmetic changes (mentioned in the second-list below), this file is perfectly identical to the original that may be found on the Apache Website: apache.org.

    1. The suggested license for using this file may be read here: Apache License
    2. The Source-Code Header for this file may be viewed here: Source-File Header
    3. Partial contents of the 'site/resources/images' directory: Resource Images

    Notes about changes that have been made as a result of the import process:

    • Within all files, the original Package-Name declaration has been changed:
      Original:   package org.apache.commons.cli;
      Updated:   package Apache.CLI;

    • All Classes and Class-Members (Methods, Fields, etc...) that were previously Annotated with the @Deprecated Annotation have been summarily removed.

    • Code Formattings and Styling has been heavily modified to conform to the Standard Java-HTML Indentation & Styling Choices. The code itself remains identical, with only a few squiggly-braces '{' and '}' being removed, for cosmetic reasons (and for lowering "Developer Stress" Levels)..
    A formatter of help messages for command line options. See example below:

    Example:
     Options options = new Options();
     
     options.addOption(
          OptionBuilder
              .withLongOpt("file")
              .withDescription("The file to be processed")
              .hasArg()
              .withArgName("FILE")
              .isRequired()
              .create('f')
     );
     
     options.addOption(
          OptionBuilder
              .withLongOpt("version")
              .withDescription("Print the version of the application")
              .create('v')
     );
     
     options.addOption(OptionBuilder.withLongOpt("help").create('h'));
    
     String header = "Do something useful with an input file\n\n";
     String footer = "\nPlease report issues at http://example.com/issues";
    
     HelpFormatter formatter = new HelpFormatter();
     formatter.printHelp("myapp", header, options, footer, true);
    


    This produces the following output:

     usage: myapp -f <FILE> [-h] [-v]
     Do something useful with an input file
    
      -f,--file <FILE>   The file to be processed
      -h,--help
      -v,--version       Print the version of the application
    
     Please report issues at http://example.com/issues
     


    • Constructor Summary

      Constructors 
      Constructor Description
      HelpFormatter()  
    • Method Summary

       
      Set Printer / Formatter Configurations
      Modifier and Type Method
      void setArgName​(String name)
      Sets the 'argName'.
      void setDescPadding​(int padding)
      Sets the 'descPadding'.
      void setLeftPadding​(int padding)
      Sets the 'leftPadding'.
      void setLongOptPrefix​(String prefix)
      Sets the 'longOptPrefix'.
      void setLongOptSeparator​(String longOptSeparator)
      Sets the separator displayed between a long option and its value.
      void setNewLine​(String newline)
      Sets the 'newLine'.
      void setOptionComparator​(Comparator<Option> comparator)
      Sets the comparator used to sort the options when they output in help text.
      void setOptPrefix​(String prefix)
      Sets the 'optPrefix'.
      void setSyntaxPrefix​(String prefix)
      Sets the 'syntaxPrefix'.
      void setWidth​(int width)
      Sets the 'width'.
       
      Print Help
      Modifier and Type Method
      void printHelp​(int width, String cmdLineSyntax, String header, Options options, String footer)
      Print the help for options with the specified command line syntax.
      void printHelp​(int width, String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
      Print the help for options with the specified command line syntax.
      void printHelp​(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer)
      Print the help for options with the specified command line syntax.
      void printHelp​(PrintWriter pw, int width, String cmdLineSyntax, String header, Options options, int leftPad, int descPad, String footer, boolean autoUsage)
      Print the help for options with the specified command line syntax.
      void printHelp​(String cmdLineSyntax, Options options)
      Print the help for options with the specified command line syntax.
      void printHelp​(String cmdLineSyntax, Options options, boolean autoUsage)
      Print the help for options with the specified command line syntax.
      void printHelp​(String cmdLineSyntax, String header, Options options, String footer)
      Print the help for options with the specified command line syntax.
      void printHelp​(String cmdLineSyntax, String header, Options options, String footer, boolean autoUsage)
      Print the help for options with the specified command line syntax.
      void printOptions​(PrintWriter pw, int width, Options options, int leftPad, int descPad)
      Print the help for the specified Options to the specified writer, using the specified width, left padding and description padding.
      void printUsage​(PrintWriter pw, int width, String cmdLineSyntax)
      Print the cmdLineSyntax to the specified writer, using the specified width.
      void printUsage​(PrintWriter pw, int width, String app, Options options)
      Prints the usage statement for the specified application.
      void printWrapped​(PrintWriter pw, int width, int nextLineTabStop, String text)
      Print the specified text to the specified PrintWriter.
      void printWrapped​(PrintWriter pw, int width, String text)
      Print the specified text to the specified PrintWriter.
       
      Retrieve Formatter Configurations
      Modifier and Type Method
      String getArgName()
      Gets the 'argName'.
      int getDescPadding()
      Gets the 'descPadding'.
      int getLeftPadding()
      Gets the 'leftPadding'.
      String getLongOptPrefix()
      Gets the 'longOptPrefix'.
      String getLongOptSeparator()
      Gets the separator displayed between a long option and its value.
      String getNewLine()
      Gets the 'newLine'.
      Comparator<Option> getOptionComparator()
      Comparator used to sort the options when they output in help text.
      String getOptPrefix()
      Gets the 'optPrefix'.
      String getSyntaxPrefix()
      Gets the 'syntaxPrefix'.
      int getWidth()
      Gets the 'width'.
       
      Protected, Internal Methods
      Modifier and Type Method
      protected String createPadding​(int len)
      Return a String of padding of length len.
      protected int findWrapPos​(String text, int width, int startPos)
      Finds the next text wrap position after startPos for the text in text with the column width width.
      protected StringBuffer renderOptions​(StringBuffer sb, int width, Options options, int leftPad, int descPad)
      Render the specified Options and return the rendered Options in a StringBuffer.
      protected StringBuffer renderWrappedText​(StringBuffer sb, int width, int nextLineTabStop, String text)
      Render the specified text and return the rendered Options in a StringBuffer.
      protected String rtrim​(String s)
      Remove the trailing whitespace from the specified String.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • createPadding

        🡅  🡇     🗕  🗗  🗖
        protected java.lang.String createPadding​(int len)
        Return a String of padding of length len.
        Parameters:
        len - The length of the String of padding to create.
        Returns:
        The String of padding
        Code:
        Exact Method Body:
         final char[] padding = new char[len];
         Arrays.fill(padding, ' ');
        
         return new String(padding);
        
      • findWrapPos

        🡅  🡇     🗕  🗗  🗖
        protected int findWrapPos​(java.lang.String text,
                                  int width,
                                  int startPos)
        Finds the next text wrap position after startPos for the text in text with the column width width. The wrap point is the last position before startPos+width having a whitespace character (space, \n, \r). If there is no whitespace character before startPos+width, it will return startPos+width.
        Parameters:
        text - The text being searched for the wrap position
        width - width of the wrapped text
        startPos - position from which to start the lookup whitespace character
        Returns:
        position on which the text must be wrapped or -1 if the wrap position is at the end of the text
        Code:
        Exact Method Body:
         // the line ends before the max wrap pos or a new line char found
         int pos = text.indexOf('\n', startPos);
        
         if (pos != -1 && pos <= width) return pos + 1;
        
         pos = text.indexOf('\t', startPos);
         if (pos != -1 && pos <= width) return pos + 1;
        
         if (startPos + width >= text.length()) return -1;
        
         // look for the last whitespace character before startPos+width
         for (pos = startPos + width; pos >= startPos; --pos)
         {
             final char c = text.charAt(pos);
             if (c == ' ' || c == '\n' || c == '\r') break;
         }
        
         // if we found it - just return
         if (pos > startPos) return pos;
        
         // if we didn't find one, simply chop at startPos+width
         pos = startPos + width;
        
         return pos == text.length() ? -1 : pos;
        
      • getArgName

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getArgName()
        Gets the 'argName'.
        Returns:
        the 'argName'
        Code:
        Exact Method Body:
         return defaultArgName;
        
      • getLongOptPrefix

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getLongOptPrefix()
        Gets the 'longOptPrefix'.
        Returns:
        the 'longOptPrefix'
        Code:
        Exact Method Body:
         return defaultLongOptPrefix;
        
      • getLongOptSeparator

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getLongOptSeparator()
        Gets the separator displayed between a long option and its value.
        Returns:
        the separator
        Code:
        Exact Method Body:
         return longOptSeparator;
        
      • getNewLine

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getNewLine()
        Gets the 'newLine'.
        Returns:
        the 'newLine'
        Code:
        Exact Method Body:
         return defaultNewLine;
        
      • getOptionComparator

        🡅  🡇     🗕  🗗  🗖
        public java.util.Comparator<OptiongetOptionComparator()
        Comparator used to sort the options when they output in help text. Defaults to case-insensitive alphabetical sorting by option key.
        Returns:
        the Comparator currently in use to sort the
        Code:
        Exact Method Body:
         return optionComparator;
        
      • getOptPrefix

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getOptPrefix()
        Gets the 'optPrefix'.
        Returns:
        the 'optPrefix'
        Code:
        Exact Method Body:
         return defaultOptPrefix;
        
      • getSyntaxPrefix

        🡅  🡇     🗕  🗗  🗖
        public java.lang.String getSyntaxPrefix()
        Gets the 'syntaxPrefix'.
        Returns:
        the 'syntaxPrefix'
        Code:
        Exact Method Body:
         return defaultSyntaxPrefix;
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(int width,
                              java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              java.lang.String footer)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        width - the number of characters to be displayed on each line
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        footer - the banner to display at the end of the help
        Code:
        Exact Method Body:
         printHelp(width, cmdLineSyntax, header, options, footer, false);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(int width,
                              java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              java.lang.String footer,
                              boolean autoUsage)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        width - the number of characters to be displayed on each line
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        footer - the banner to display at the end of the help
        autoUsage - whether to print an automatically generated usage statement
        Code:
        Exact Method Body:
         final PrintWriter pw = new PrintWriter(System.out);
        
         printHelp(
             pw, width, cmdLineSyntax, header, options, getLeftPadding(), getDescPadding(), footer,
             autoUsage
         );
        
         pw.flush();
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.io.PrintWriter pw,
                              int width,
                              java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              int leftPad,
                              int descPad,
                              java.lang.String footer)
        Print the help for options with the specified command line syntax.
        Parameters:
        pw - the writer to which the help will be written
        width - the number of characters to be displayed on each line
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        leftPad - the number of characters of padding to be prefixed to each line
        descPad - the number of characters of padding to be prefixed to each description line
        footer - the banner to display at the end of the help
        Throws:
        java.lang.IllegalStateException - if there is no room to print a line
        Code:
        Exact Method Body:
         printHelp(pw, width, cmdLineSyntax, header, options, leftPad, descPad, footer, false);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.io.PrintWriter pw,
                              int width,
                              java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              int leftPad,
                              int descPad,
                              java.lang.String footer,
                              boolean autoUsage)
        Print the help for options with the specified command line syntax.
        Parameters:
        pw - the writer to which the help will be written
        width - the number of characters to be displayed on each line
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        leftPad - the number of characters of padding to be prefixed to each line
        descPad - the number of characters of padding to be prefixed to each description line
        footer - the banner to display at the end of the help
        autoUsage - whether to print an automatically generated usage statement
        Throws:
        java.lang.IllegalStateException - if there is no room to print a line
        Code:
        Exact Method Body:
         if (cmdLineSyntax == null || cmdLineSyntax.isEmpty())
             throw new IllegalArgumentException("cmdLineSyntax not provided");
        
         if (autoUsage)  printUsage(pw, width, cmdLineSyntax, options);
         else            printUsage(pw, width, cmdLineSyntax);
        
         if (header != null && !header.isEmpty()) printWrapped(pw, width, header);
        
         printOptions(pw, width, options, leftPad, descPad);
        
         if (footer != null && !footer.isEmpty()) printWrapped(pw, width, footer);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.lang.String cmdLineSyntax,
                              Options options)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        cmdLineSyntax - the syntax for this application
        options - the Options instance
        Code:
        Exact Method Body:
         printHelp(getWidth(), cmdLineSyntax, null, options, null, false);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.lang.String cmdLineSyntax,
                              Options options,
                              boolean autoUsage)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        cmdLineSyntax - the syntax for this application
        options - the Options instance
        autoUsage - whether to print an automatically generated usage statement
        Code:
        Exact Method Body:
         printHelp(getWidth(), cmdLineSyntax, null, options, null, autoUsage);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              java.lang.String footer)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        footer - the banner to display at the end of the help
        Code:
        Exact Method Body:
         printHelp(cmdLineSyntax, header, options, footer, false);
        
      • printHelp

        🡅  🡇     🗕  🗗  🗖
        public void printHelp​(java.lang.String cmdLineSyntax,
                              java.lang.String header,
                              Options options,
                              java.lang.String footer,
                              boolean autoUsage)
        Print the help for options with the specified command line syntax. This method prints help information to System.out.
        Parameters:
        cmdLineSyntax - the syntax for this application
        header - the banner to display at the beginning of the help
        options - the Options instance
        footer - the banner to display at the end of the help
        autoUsage - whether to print an automatically generated usage statement
        Code:
        Exact Method Body:
         printHelp(getWidth(), cmdLineSyntax, header, options, footer, autoUsage);
        
      • printOptions

        🡅  🡇     🗕  🗗  🗖
        public void printOptions​(java.io.PrintWriter pw,
                                 int width,
                                 Options options,
                                 int leftPad,
                                 int descPad)
        Print the help for the specified Options to the specified writer, using the specified width, left padding and description padding.
        Parameters:
        pw - The printWriter to write the help to
        width - The number of characters to display per line
        options - The command line Options
        leftPad - the number of characters of padding to be prefixed to each line
        descPad - the number of characters of padding to be prefixed to each description line
        Code:
        Exact Method Body:
         final StringBuffer sb = new StringBuffer();
        
         renderOptions(sb, width, options, leftPad, descPad);
         pw.println(sb.toString());
        
      • printUsage

        🡅  🡇     🗕  🗗  🗖
        public void printUsage​(java.io.PrintWriter pw,
                               int width,
                               java.lang.String cmdLineSyntax)
        Print the cmdLineSyntax to the specified writer, using the specified width.
        Parameters:
        pw - The printWriter to write the help to
        width - The number of characters per line for the usage statement.
        cmdLineSyntax - The usage statement.
        Code:
        Exact Method Body:
         final int argPos = cmdLineSyntax.indexOf(' ') + 1;
        
         printWrapped
             (pw, width, getSyntaxPrefix().length() + argPos, getSyntaxPrefix() + cmdLineSyntax);
        
      • printUsage

        🡅  🡇     🗕  🗗  🗖
        public void printUsage​(java.io.PrintWriter pw,
                               int width,
                               java.lang.String app,
                               Options options)
        Prints the usage statement for the specified application.
        Parameters:
        pw - The PrintWriter to print the usage statement
        width - The number of characters to display per line
        app - The application name
        options - The command line Options
        Code:
        Exact Method Body:
         // initialize the string buffer
         final StringBuffer buff = new StringBuffer(getSyntaxPrefix()).append(app).append(" ");
        
         // create a list for processed option groups
         final Collection<OptionGroup> processedGroups = new ArrayList<>();
        
         final List<Option> optList = new ArrayList<>(options.getOptions());
        
         if (getOptionComparator() != null)
             Collections.sort(optList, getOptionComparator());
        
         // iterate over the options
         for (final Iterator<Option> it = optList.iterator(); it.hasNext();)
         {
             // get the next Option
             final Option option = it.next();
        
             // check if the option is part of an OptionGroup
             final OptionGroup group = options.getOptionGroup(option);
        
             // if the option is part of a group
             if (group != null)
             {
                 // and if the group has not already been processed
                 if (!processedGroups.contains(group))
                 {
                     // add the group to the processed list
                     processedGroups.add(group);
        
                     // add the usage clause
                     appendOptionGroup(buff, group);
                 }
        
                 // otherwise the option was displayed in the group
                 // previously so ignore it.
             }
        
             // if the Option is not part of an OptionGroup
             else appendOption(buff, option, option.isRequired());
        
             if (it.hasNext()) buff.append(" ");
         }
        
         // call printWrapped
         printWrapped(pw, width, buff.toString().indexOf(' ') + 1, buff.toString());
        
      • printWrapped

        🡅  🡇     🗕  🗗  🗖
        public void printWrapped​(java.io.PrintWriter pw,
                                 int width,
                                 int nextLineTabStop,
                                 java.lang.String text)
        Print the specified text to the specified PrintWriter.
        Parameters:
        pw - The printWriter to write the help to
        width - The number of characters to display per line
        nextLineTabStop - The position on the next line for the first tab.
        text - The text to be written to the PrintWriter
        Code:
        Exact Method Body:
         final StringBuffer sb = new StringBuffer(text.length());
        
         renderWrappedTextBlock(sb, width, nextLineTabStop, text);
         pw.println(sb.toString());
        
      • printWrapped

        🡅  🡇     🗕  🗗  🗖
        public void printWrapped​(java.io.PrintWriter pw,
                                 int width,
                                 java.lang.String text)
        Print the specified text to the specified PrintWriter.
        Parameters:
        pw - The printWriter to write the help to
        width - The number of characters to display per line
        text - The text to be written to the PrintWriter
        Code:
        Exact Method Body:
         printWrapped(pw, width, 0, text);
        
      • renderOptions

        🡅  🡇     🗕  🗗  🗖
        protected java.lang.StringBuffer renderOptions​(java.lang.StringBuffer sb,
                                                       int width,
                                                       Options options,
                                                       int leftPad,
                                                       int descPad)
        Render the specified Options and return the rendered Options in a StringBuffer.
        Parameters:
        sb - The StringBuffer to place the rendered Options into.
        width - The number of characters to display per line
        options - The command line Options
        leftPad - the number of characters of padding to be prefixed to each line
        descPad - the number of characters of padding to be prefixed to each description line
        Returns:
        the StringBuffer with the rendered Options contents.
        Code:
        Exact Method Body:
         final String lpad = createPadding(leftPad);
         final String dpad = createPadding(descPad);
        
         // first create list containing only <lpad>-a,--aaa where
         // -a is opt and --aaa is long opt; in parallel look for
         // the longest opt string this list will be then used to
         // sort options ascending
        
         int max = 0;
         final List<StringBuffer> prefixList = new ArrayList<>();
        
         final List<Option> optList = options.helpOptions();
        
         if (getOptionComparator() != null)
             Collections.sort(optList, getOptionComparator());
        
         for (final Option option : optList)
         {
             final StringBuffer optBuf = new StringBuffer();
        
             if (option.getOpt() == null) optBuf
                 .append(lpad)
                 .append("   ")
                 .append(getLongOptPrefix())
                 .append(option.getLongOpt());
        
             else
             {
                 optBuf.append(lpad).append(getOptPrefix()).append(option.getOpt());
        
                 if (option.hasLongOpt())
                     optBuf.append(',').append(getLongOptPrefix()).append(option.getLongOpt());
             }
        
             if (option.hasArg())
             {
                 final String argName = option.getArgName();
        
                 if (argName != null && argName.isEmpty())
        
                     // if the option has a blank argname
                     optBuf.append(' ');
        
                 else
                 {
                     optBuf.append(option.hasLongOpt() ? longOptSeparator : " ");
        
                     optBuf
                         .append("<")
                         .append(argName != null 
                             ? option.getArgName() 
                             : getArgName()
                         )
                         .append(">");
                 }
             }
        
             prefixList.add(optBuf);
             max = Math.max(optBuf.length(), max);
         }
        
         int x = 0;
        
         for (final Iterator<Option> it = optList.iterator(); it.hasNext();)
         {
             final Option option = it.next();
             final StringBuilder optBuf = new StringBuilder(prefixList.get(x++).toString());
        
             if (optBuf.length() < max) optBuf.append(createPadding(max - optBuf.length()));
        
             optBuf.append(dpad);
        
             final int nextLineTabStop = max + descPad;
        
             if (option.getDescription() != null) optBuf.append(option.getDescription());
        
             renderWrappedText(sb, width, nextLineTabStop, optBuf.toString());
        
             if (it.hasNext()) sb.append(getNewLine());
         }
        
         return sb;
        
      • renderWrappedText

        🡅  🡇     🗕  🗗  🗖
        protected java.lang.StringBuffer renderWrappedText​
                    (java.lang.StringBuffer sb,
                     int width,
                     int nextLineTabStop,
                     java.lang.String text)
        
        Render the specified text and return the rendered Options in a StringBuffer.
        Parameters:
        sb - The StringBuffer to place the rendered text into.
        width - The number of characters to display per line
        nextLineTabStop - The position on the next line for the first tab.
        text - The text to be rendered.
        Returns:
        the StringBuffer with the rendered Options contents.
        Code:
        Exact Method Body:
         int pos = findWrapPos(text, width, 0);
        
         if (pos == -1)
         {
             sb.append(rtrim(text));
             return sb;
         }
        
         sb.append(rtrim(text.substring(0, pos))).append(getNewLine());
        
         if (nextLineTabStop >= width)
        
             // stops infinite loop happening
             nextLineTabStop = 1;
        
         // all following lines must be padded with nextLineTabStop space characters
         final String padding = createPadding(nextLineTabStop);
        
         while (true)
         {
             text    = padding + text.substring(pos).trim();
             pos     = findWrapPos(text, width, 0);
        
             if (pos == -1)
             {
                 sb.append(text);
        
                 return sb;
             }
        
             if (text.length() > width && pos == nextLineTabStop - 1) pos = width;
        
             sb.append(rtrim(text.substring(0, pos))).append(getNewLine());
         }
        
      • rtrim

        🡅  🡇     🗕  🗗  🗖
        protected java.lang.String rtrim​(java.lang.String s)
        Remove the trailing whitespace from the specified String.
        Parameters:
        s - The String to remove the trailing padding from.
        Returns:
        The String of without the trailing padding
        Code:
        Exact Method Body:
         if (s == null || s.isEmpty()) return s;
        
         int pos = s.length();
        
         while (pos > 0 && Character.isWhitespace(s.charAt(pos - 1))) --pos;
        
         return s.substring(0, pos);
        
      • setArgName

        🡅  🡇     🗕  🗗  🗖
        public void setArgName​(java.lang.String name)
        Sets the 'argName'.
        Parameters:
        name - the new value of 'argName'
        Code:
        Exact Method Body:
         this.defaultArgName = name;
        
      • setDescPadding

        🡅  🡇     🗕  🗗  🗖
        public void setDescPadding​(int padding)
        Sets the 'descPadding'.
        Parameters:
        padding - the new value of 'descPadding'
        Code:
        Exact Method Body:
         this.defaultDescPad = padding;
        
      • setLeftPadding

        🡅  🡇     🗕  🗗  🗖
        public void setLeftPadding​(int padding)
        Sets the 'leftPadding'.
        Parameters:
        padding - the new value of 'leftPadding'
        Code:
        Exact Method Body:
         this.defaultLeftPad = padding;
        
      • setLongOptPrefix

        🡅  🡇     🗕  🗗  🗖
        public void setLongOptPrefix​(java.lang.String prefix)
        Sets the 'longOptPrefix'.
        Parameters:
        prefix - the new value of 'longOptPrefix'
        Code:
        Exact Method Body:
         this.defaultLongOptPrefix = prefix;
        
      • setLongOptSeparator

        🡅  🡇     🗕  🗗  🗖
        public void setLongOptSeparator​(java.lang.String longOptSeparator)
        Sets the separator displayed between a long option and its value. Ensure that the separator specified is supported by the parser used, typically ' ' or '='.
        Parameters:
        longOptSeparator - the separator, typically ' ' or '='.
        Code:
        Exact Method Body:
         this.longOptSeparator = longOptSeparator;
        
      • setNewLine

        🡅  🡇     🗕  🗗  🗖
        public void setNewLine​(java.lang.String newline)
        Sets the 'newLine'.
        Parameters:
        newline - the new value of 'newLine'
        Code:
        Exact Method Body:
         this.defaultNewLine = newline;
        
      • setOptionComparator

        🡅  🡇     🗕  🗗  🗖
        public void setOptionComparator​(java.util.Comparator<Option> comparator)
        Sets the comparator used to sort the options when they output in help text. Passing in a null comparator will keep the options in the order they were declared.
        Parameters:
        comparator - the Comparator to use for sorting the options
        Code:
        Exact Method Body:
         this.optionComparator = comparator;
        
      • setOptPrefix

        🡅  🡇     🗕  🗗  🗖
        public void setOptPrefix​(java.lang.String prefix)
        Sets the 'optPrefix'.
        Parameters:
        prefix - the new value of 'optPrefix'
        Code:
        Exact Method Body:
         this.defaultOptPrefix = prefix;
        
      • setSyntaxPrefix

        🡅  🡇     🗕  🗗  🗖
        public void setSyntaxPrefix​(java.lang.String prefix)
        Sets the 'syntaxPrefix'.
        Parameters:
        prefix - the new value of 'syntaxPrefix'
        Code:
        Exact Method Body:
         this.defaultSyntaxPrefix = prefix;
        
      • setWidth

        🡅     🗕  🗗  🗖
        public void setWidth​(int width)
        Sets the 'width'.
        Parameters:
        width - the new value of 'width'
        Code:
        Exact Method Body:
         this.defaultWidth = width;