A help formatter that allows configuration of overall row width and column separator width.
The formatter produces output in two sections: one for the options, and one for non-option arguments.
The options section has two columns: the left column for the options, and the right column for their descriptions. The formatter will allow as much space as possible for the descriptions, by minimizing the option column's width, no greater than slightly less than half the overall desired width.
The non-option arguments section is one column, occupying as much width as it can.
Subclasses are free to override bits of this implementation as they see fit. Inspect the code carefully to understand the flow of control that this implementation guarantees.
| Access | Constructor and Description |
|---|---|
| pack-priv | BuiltinHelpFormatter()
Makes a formatter with a pre-configured overall row width and column separator width. |
| public | BuiltinHelpFormatter(int
how many characters wide to make the overall help display desiredOverallWidth, int how many characters wide to make the separation between option column and
description column desiredColumnSeparatorWidth)Makes a formatter with a given overall row width and column separator width. |
| Modifier and Type | Method and Description |
|---|---|
| protected void | addHeaders(Collection<? extends OptionDescriptor>
descriptors for the configured options of a parser options)Adds help row headers for option help columns. |
| protected void | addNonOptionRow(String
single row of non-option argument help text single)Adds a single row of non-option argument help. |
| protected void | addNonOptionsDescription(Collection<? extends OptionDescriptor>
descriptors for the configured options of a parser options)Adds non-option arguments descriptions to the help output. |
| protected void | addOptionRow(String
text to put in the left column single)Adds a row of option help output in the left column, with empty space in the right column. |
| protected void | addOptionRow(String
text to put in the left column left, String text to put in the right column right)Adds a row of option help output in the left and right columns. |
| protected void | addOptions(Collection<? extends OptionDescriptor>
descriptors for the configured options of a parser options)Adds help rows for the given options. |
| protected void | addRows(Collection<? extends OptionDescriptor>
descriptors for the configured options of a parser options)Adds rows of help output for the given options. |
| protected void | appendOptionHelp(StringBuilder
string buffer buffer, String type indicator typeIndicator, String type description description, boolean indicator of "required"-ness of the argument of the option required)Appends info about an option's argument to the given buffer. |
| protected void | appendTypeIndicator(StringBuilder
string buffer buffer, String type indicator typeIndicator, String type description description, char starting character start, char ending character end)Appends a type indicator for an option's argument to the given buffer. |
| protected String | Returns: a display string for those default valuessome default values for a given option's argument defaultValues)Gives a display string for the default values of an option's argument. |
| protected String | Returns: display text for the option's descriptiona descriptor for a configured option of a parser descriptor)Gives a string representing a description of the option with the given descriptor. |
| protected String | Returns: help string for non-optionsnon-option argument descriptor nonOptionDescriptor)Creates a non-options argument help string. |
| protected String | Returns: help stringa descriptor for a configured option of a parser descriptor)Creates a string for how the given option descriptor is to be represented in help. |
| protected String | Returns: type indicator texta descriptor for a configured option of a parser descriptor)Gives an indicator of the type of arguments of the option described by the given descriptor, for use in help. |
| protected OptionDescriptor | Returns: the non-option arguments descriptordescriptors for the configured options of a parser options)Finds the non-option arguments descriptor in the given collection, removes it, and returns it. |
| protected void | fitRowsToWidth()
Resizes the columns of all the rows to be no wider than the widest element in that column. |
| public String | format(Map<String, ? extends OptionDescriptor>
descriptors for the configured options of a parser options)Implements joptsimple. |
| protected String | Returns: help output for entire set of options and non-option argumentsProduces help output for an entire set of options and non-option arguments. |
| protected final boolean | Returns: true if at least one of the options is "required"descriptors for the configured options of a parser options)Tells whether the given option descriptors contain a "required" option. |
| protected void | maybeAppendNonOptionsDescription(StringBuilder
string buffer buffer, OptionDescriptor non-option arguments descriptor nonOptions)Appends help for the given non-option arguments descriptor to the given buffer. |
| protected void | maybeAppendOptionInfo(StringBuilder
string buffer buffer, OptionDescriptor a descriptor for a configured option of a parser descriptor)Appends additional info about the given option to the given buffer. |
| protected String | |
| protected String | |
| protected String | Returns: an "option leader" stringa string option option)Gives a string that represents the given option's "option leader" in help. |
| protected String | |
| protected boolean | Returns: true if non-options argument help should be shownnon-option argument descriptor nonOptionDescriptor)Decides whether or not to show a non-option arguments help. |
| nonOptionRows | back to summary |
|---|---|
| private final Rows nonOptionRows | |
| optionRows | back to summary |
|---|---|
| private final Rows optionRows | |
| BuiltinHelpFormatter | back to summary |
|---|---|
| pack-priv BuiltinHelpFormatter() Makes a formatter with a pre-configured overall row width and column separator width. | |
| BuiltinHelpFormatter | back to summary |
|---|---|
| public BuiltinHelpFormatter(int desiredOverallWidth, int desiredColumnSeparatorWidth) Makes a formatter with a given overall row width and column separator width.
| |
| addHeaders | back to summary |
|---|---|
| protected void addHeaders(Collection<? extends OptionDescriptor> options) Adds help row headers for option help columns. This implementation uses the headers
| |
| addNonOptionRow | back to summary |
|---|---|
| protected void addNonOptionRow(String single) Adds a single row of non-option argument help.
| |
| addNonOptionsDescription | back to summary |
|---|---|
| protected void addNonOptionsDescription(Collection<? extends OptionDescriptor> options) Adds non-option arguments descriptions to the help output. This implementation:
| |
| addOptionRow | back to summary |
|---|---|
| protected void addOptionRow(String single) Adds a row of option help output in the left column, with empty space in the right column.
| |
| addOptionRow | back to summary |
|---|---|
| protected void addOptionRow(String left, String right) Adds a row of option help output in the left and right columns. | |
| addOptions | back to summary |
|---|---|
| protected void addOptions(Collection<? extends OptionDescriptor> options) Adds help rows for the given options. This implementation loops over the given options, and for each, calls
| |
| addRows | back to summary |
|---|---|
| protected void addRows(Collection<? extends OptionDescriptor> options) Adds rows of help output for the given options. This implementation:
| |
| appendOptionHelp | back to summary |
|---|---|
| protected void appendOptionHelp(StringBuilder buffer, String typeIndicator, String description, boolean required) Appends info about an option's argument to the given buffer. This implementation calls
| |
| appendTypeIndicator | back to summary |
|---|---|
| protected void appendTypeIndicator(StringBuilder buffer, String typeIndicator, String description, char start, char end) Appends a type indicator for an option's argument to the given buffer. This implementation appends, in order:
| |
| createDefaultValuesDisplay | back to summary |
|---|---|
| protected String createDefaultValuesDisplay(List<?> defaultValues) Gives a display string for the default values of an option's argument. This implementation gives the | |
| createDescriptionDisplay | back to summary |
|---|---|
| protected String createDescriptionDisplay(OptionDescriptor descriptor) Gives a string representing a description of the option with the given descriptor. This implementation:
| |
| createNonOptionArgumentsDisplay | back to summary |
|---|---|
| protected String createNonOptionArgumentsDisplay(OptionDescriptor nonOptionDescriptor) Creates a non-options argument help string. This implementation creates an empty string buffer and calls
| |
| createOptionDisplay | back to summary |
|---|---|
| protected String createOptionDisplay(OptionDescriptor descriptor) Creates a string for how the given option descriptor is to be represented in help. This implementation gives a string consisting of the concatenation of:
| |
| extractTypeIndicator | back to summary |
|---|---|
| protected String extractTypeIndicator(OptionDescriptor descriptor) Gives an indicator of the type of arguments of the option described by the given descriptor, for use in help. This implementation asks for the
| |
| findAndRemoveNonOptionsSpec | back to summary |
|---|---|
| protected OptionDescriptor findAndRemoveNonOptionsSpec(Collection<? extends OptionDescriptor> options) Finds the non-option arguments descriptor in the given collection, removes it, and returns it.
| |
| fitRowsToWidth | back to summary |
|---|---|
| protected void fitRowsToWidth() Resizes the columns of all the rows to be no wider than the widest element in that column. | |
| format | back to summary |
|---|---|
| public String format(Map<String, ? extends OptionDescriptor> options) Implements joptsimple. Doc from joptsimple. Produces help text, given a set of option descriptors. This implementation:
| |
| formattedHelpOutput | back to summary |
|---|---|
| protected String formattedHelpOutput() Produces help output for an entire set of options and non-option arguments. This implementation concatenates:
| |
| hasRequiredOption | back to summary |
|---|---|
| protected final boolean hasRequiredOption(Collection<? extends OptionDescriptor> options) Tells whether the given option descriptors contain a "required" option.
| |
| maybeAppendNonOptionsDescription | back to summary |
|---|---|
| protected void maybeAppendNonOptionsDescription(StringBuilder buffer, OptionDescriptor nonOptions) Appends help for the given non-option arguments descriptor to the given buffer. This implementation appends
| |
| maybeAppendOptionInfo | back to summary |
|---|---|
| protected void maybeAppendOptionInfo(StringBuilder buffer, OptionDescriptor descriptor) Appends additional info about the given option to the given buffer. This implementation:
| |
| message | back to summary |
|---|---|
| protected String message(String keySuffix, Object... args) Looks up and gives a resource bundle message. This implementation looks in the bundle | |
| nonOptionOutput | back to summary |
|---|---|
| protected String nonOptionOutput() Produces non-option argument help.
| |
| optionLeader | back to summary |
|---|---|
| protected String optionLeader(String option) Gives a string that represents the given option's "option leader" in help. This implementation answers with | |
| optionOutput | back to summary |
|---|---|
| protected String optionOutput() Produces help for options and their descriptions.
| |
| shouldShowNonOptionArgumentDisplay | back to summary |
|---|---|
| protected boolean shouldShowNonOptionArgumentDisplay(OptionDescriptor nonOptionDescriptor) Decides whether or not to show a non-option arguments help. This implementation responds with
| |