public void usage ( StringBuilder out , String indent ) { if ( commander . getDescriptions ( ) == null ) { commander . createDescriptions ( ) ; } boolean hasCommands = ! commander . getCommands ( ) . isEmpty ( ) ; boolean hasOptions = ! commander . getDescriptions ( ) . isEmpty ( ) ; // Indentation constants final int descriptionIndent = 6 ; final int indentCount = indent . length ( ) + descriptionIndent ; // Append first line (aka main line) of the usage appendMainLine ( out , hasOptions , hasCommands , indentCount , indent ) ; // Align the descriptions at the "longestName" column int longestName = 0 ; List < ParameterDescription > sortedParameters = Lists . newArrayList ( ) ; for ( ParameterDescription pd : commander . getFields ( ) . values ( ) ) { if ( ! pd . getParameter ( ) . hidden ( ) ) { sortedParameters . add ( pd ) ; // + to have an extra space between the name and the description int length = pd . getNames ( ) . length ( ) + 2 ; if ( length > longestName ) { longestName = length ; } } } // Sort the options sortedParameters . sort ( commander . getParameterDescriptionComparator ( ) ) ; // Append all the parameter names and descriptions appendAllParametersDetails ( out , indentCount , indent , sortedParameters ) ; // Append commands if they were specified if ( hasCommands ) { appendCommands ( out , indentCount , descriptionIndent , indent ) ; } }
Stores the usage in the argument string builder with the argument indentation . This works by appending each portion of the help in the following order . Their outputs can be modified by overriding them in a subclass of this class .