Class CommandLine.Help.Layout
- Enclosing class:
- CommandLine.Help
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.
-
Field Summary
Modifier and TypeFieldDescriptionprotected final CommandLine.Help.ColorScheme
protected CommandLine.Help.IOptionRenderer
protected CommandLine.Help.IParameterRenderer
protected final CommandLine.Help.TextTable
-
Constructor Summary
ConstructorDescriptionLayout
(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.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. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addOption
(CommandLine.Model.OptionSpec option, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) Delegates to theoption renderer
of this layout to obtain text values for the specifiedCommandLine.Model.OptionSpec
, and then calls thelayout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
method to write these text values into the correct cells in the TextTable.void
addOptions
(List<CommandLine.Model.OptionSpec> options, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) CallsaddOption(CommandLine.Model.OptionSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Options in the list.void
addPositionalParameter
(CommandLine.Model.PositionalParamSpec param, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) Delegates to theparameter renderer
of this layout to obtain text values for the specified positional parameter, and then callslayout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
to write these text values into the correct cells in the TextTable.void
addPositionalParameters
(List<CommandLine.Model.PositionalParamSpec> params, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) CallsaddPositionalParameter(CommandLine.Model.PositionalParamSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Parameters in the list.void
layout
(CommandLine.Model.ArgSpec argSpec, CommandLine.Help.Ansi.Text[][] cellValues) Copies the specified text values into the correct cells in theCommandLine.Help.TextTable
.toString()
Returns the section of the usage help message accumulated in the TextTable owned by this layout.
-
Field Details
-
colorScheme
-
table
-
optionRenderer
-
parameterRenderer
-
-
Constructor Details
-
Layout
Constructs a Layout with the specified color scheme, a new default TextTable, the default option renderer, and the default parameter renderer.- Parameters:
colorScheme
- the color scheme to use for common, auto-generated parts of the usage help message
-
Layout
Constructs a Layout with the specified color scheme, the specified TextTable, the default option renderer, and the default parameter renderer.- Parameters:
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 format
-
Layout
public 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.- Parameters:
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 format
-
-
Method Details
-
layout
Copies the specified text values into the correct cells in the
CommandLine.Help.TextTable
. This implementation delegates toCommandLine.Help.TextTable.addRowValues(CommandLine.Help.Ansi.Text...)
for each row of values.Subclasses may override.
- Parameters:
argSpec
- the Option or ParameterscellValues
- the text values representing the Option/Parameters, to be displayed in tabular form
-
addOptions
public void addOptions(List<CommandLine.Model.OptionSpec> options, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) CallsaddOption(CommandLine.Model.OptionSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Options in the list.- Parameters:
options
- options to add usage descriptions forparamLabelRenderer
- object that knows how to render option parameters- Since:
- 3.0
-
addOption
public void addOption(CommandLine.Model.OptionSpec option, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) Delegates to the
option renderer
of this layout to obtain text values for the specifiedCommandLine.Model.OptionSpec
, and then calls thelayout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
method to write these text values into the correct cells in the TextTable.- Parameters:
option
- the option argumentparamLabelRenderer
- knows how to render option parameters
-
addPositionalParameters
public void addPositionalParameters(List<CommandLine.Model.PositionalParamSpec> params, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) CallsaddPositionalParameter(CommandLine.Model.PositionalParamSpec, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Parameters in the list.- Parameters:
params
- positional parameters to add usage descriptions forparamLabelRenderer
- knows how to render option parameters- Since:
- 3.0
-
addPositionalParameter
public void addPositionalParameter(CommandLine.Model.PositionalParamSpec param, CommandLine.Help.IParamLabelRenderer paramLabelRenderer) Delegates to the
parameter renderer
of this layout to obtain text values for the specified positional parameter, and then callslayout(CommandLine.Model.ArgSpec, CommandLine.Help.Ansi.Text[][])
to write these text values into the correct cells in the TextTable.- Parameters:
param
- the positional parameterparamLabelRenderer
- knows how to render option parameters
-
toString
Returns the section of the usage help message accumulated in the TextTable owned by this layout.
-