public static class CommandLine.Help.Layout extends Object
Delegates to the renderers to create CommandLine.Help.Ansi.Text
values for the annotated fields, and uses a
CommandLine.Help.TextTable
to display these values in tabular format. Layout is responsible for deciding which values
to display where in the table. By default, Layout shows one option or parameter per table row.
Customize by overriding the layout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
method.
Modifier and Type | Field and Description |
---|---|
protected CommandLine.Help.ColorScheme |
colorScheme |
protected CommandLine.Help.IOptionRenderer |
optionRenderer |
protected CommandLine.Help.IParameterRenderer |
parameterRenderer |
protected CommandLine.Help.TextTable |
table |
Constructor and Description |
---|
Layout(CommandLine.Help.ColorScheme colorScheme,
CommandLine.Help.TextTable textTable)
Constructs a Layout with the specified color scheme, the specified TextTable, the
default option renderer, and the
default parameter renderer.
|
Layout(CommandLine.Help.ColorScheme colorScheme,
CommandLine.Help.TextTable textTable,
CommandLine.Help.IOptionRenderer optionRenderer,
CommandLine.Help.IParameterRenderer parameterRenderer)
Constructs a Layout with the specified color scheme, the specified TextTable, the
specified option renderer and the specified parameter renderer.
|
Layout(CommandLine.Help.ColorScheme colorScheme,
int tableWidth)
Constructs a Layout with the specified color scheme, a new default TextTable, the
default option renderer, and the
default parameter renderer.
|
protected final CommandLine.Help.ColorScheme colorScheme
protected final CommandLine.Help.TextTable table
protected CommandLine.Help.IOptionRenderer optionRenderer
protected CommandLine.Help.IParameterRenderer parameterRenderer
public Layout(CommandLine.Help.ColorScheme colorScheme, int tableWidth)
colorScheme
- the color scheme to use for common, auto-generated parts of the usage help messagepublic Layout(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.TextTable textTable)
colorScheme
- the color scheme to use for common, auto-generated parts of the usage help messagetextTable
- the TextTable to lay out parts of the usage help message in tabular formatpublic Layout(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.TextTable textTable, CommandLine.Help.IOptionRenderer optionRenderer, CommandLine.Help.IParameterRenderer parameterRenderer)
colorScheme
- the color scheme to use for common, auto-generated parts of the usage help messageoptionRenderer
- the object responsible for rendering Options to TextparameterRenderer
- the object responsible for rendering Parameters to TexttextTable
- the TextTable to lay out parts of the usage help message in tabular formatpublic void layout(CommandLine.Model.ArgSpec argSpec, CommandLine.Help.Ansi.Text[][] cellValues)
CommandLine.Help.TextTable
. This implementation
delegates to CommandLine.Help.TextTable.addRowValues(CommandLine.Help.Ansi.Text...)
for each row of values.
Subclasses may override.
argSpec
- the Option or ParameterscellValues
- the text values representing the Option/Parameters, to be displayed in tabular formpublic void addOptions(List<CommandLine.Model.OptionSpec> options, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
addOption(CommandLine.Model.OptionSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Options in the list.options
- options to add usage descriptions forparamLabelRenderer
- object that knows how to render option parameterspublic void addAllOptions(List<CommandLine.Model.OptionSpec> options, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
addOption(CommandLine.Model.OptionSpec, CommandLine.Help.IParamLabelRenderer)
for all Options in the specified list.options
- options to add usage descriptions for;
it is the responsibility of the caller to exclude options that should not be shownparamLabelRenderer
- object that knows how to render option parameterspublic void addOption(CommandLine.Model.OptionSpec option, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
option renderer
of this layout to obtain
text values for the specified CommandLine.Model.OptionSpec
, and then calls the layout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
method to write these text values into the correct cells in the TextTable.option
- the option argumentparamLabelRenderer
- knows how to render option parameterspublic void addPositionalParameters(List<CommandLine.Model.PositionalParamSpec> params, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
addPositionalParameter(CommandLine.Model.PositionalParamSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Parameters in the list.params
- positional parameters to add usage descriptions forparamLabelRenderer
- knows how to render option parameterspublic void addAllPositionalParameters(List<CommandLine.Model.PositionalParamSpec> params, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
addPositionalParameter(CommandLine.Model.PositionalParamSpec, CommandLine.Help.IParamLabelRenderer)
for all positional parameters in the specified list.params
- positional parameters to add usage descriptions for;
it is the responsibility of the caller to exclude positional parameters that should not be shownparamLabelRenderer
- knows how to render option parameterspublic void addPositionalParameter(CommandLine.Model.PositionalParamSpec param, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
parameter renderer
of this layout
to obtain text values for the specified positional parameter, and then calls
layout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
to write these text values into the correct cells in the TextTable.param
- the positional parameterparamLabelRenderer
- knows how to render option parameterspublic String toString()
public CommandLine.Help.ColorScheme colorScheme()
public CommandLine.Help.TextTable textTable()
public CommandLine.Help.IOptionRenderer optionRenderer()
public CommandLine.Help.IParameterRenderer parameterRenderer()