Package picocli
Class CommandLine.Help.Layout
- java.lang.Object
-
- picocli.CommandLine.Help.Layout
-
- Enclosing class:
- CommandLine.Help
public static class CommandLine.Help.Layout extends Object
Use a Layout to format usage help text for options and parameters in tabular format.Delegates to the renderers to create
CommandLine.Help.Ansi.Text
values for the annotated fields, and uses aCommandLine.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
Fields Modifier and Type Field Description protected CommandLine.Help.ColorScheme
colorScheme
protected CommandLine.Help.IOptionRenderer
optionRenderer
protected CommandLine.Help.IParameterRenderer
parameterRenderer
protected CommandLine.Help.TextTable
table
-
Constructor Summary
Constructors Constructor Description 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.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
-
-
-
Field Detail
-
colorScheme
protected final CommandLine.Help.ColorScheme colorScheme
-
table
protected final CommandLine.Help.TextTable table
-
optionRenderer
protected CommandLine.Help.IOptionRenderer optionRenderer
-
parameterRenderer
protected CommandLine.Help.IParameterRenderer parameterRenderer
-
-
Constructor Detail
-
Layout
public 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.- Parameters:
colorScheme
- the color scheme to use for common, auto-generated parts of the usage help message
-
Layout
public 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.- 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 Detail
-
layout
public void layout(CommandLine.Model.ArgSpec argSpec, CommandLine.Help.Ansi.Text[][] cellValues)
Copies the specified text values into the correct cells in theCommandLine.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- Since:
- 3.0
-
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
-
addAllOptions
public void addAllOptions(List<CommandLine.Model.OptionSpec> options, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddOption(CommandLine.Model.OptionSpec, CommandLine.Help.IParamLabelRenderer)
for all Options in the specified list.- Parameters:
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 parameters- Since:
- 4.4
-
addOption
public void 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.- Parameters:
option
- the option argumentparamLabelRenderer
- knows how to render option parameters- Since:
- 3.0
-
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
-
addAllPositionalParameters
public void addAllPositionalParameters(List<CommandLine.Model.PositionalParamSpec> params, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddPositionalParameter(CommandLine.Model.PositionalParamSpec, CommandLine.Help.IParamLabelRenderer)
for all positional parameters in the specified list.- Parameters:
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 parameters- Since:
- 4.4
-
addPositionalParameter
public 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.- Parameters:
param
- the positional parameterparamLabelRenderer
- knows how to render option parameters- Since:
- 3.0
-
toString
public String toString()
Returns the section of the usage help message accumulated in the TextTable owned by this layout.
-
colorScheme
public CommandLine.Help.ColorScheme colorScheme()
Returns the ColorScheme used to create Text objects in this layout.- Since:
- 4.6
-
textTable
public CommandLine.Help.TextTable textTable()
Returns the TextTable used in this layout.- Since:
- 4.6
-
optionRenderer
public CommandLine.Help.IOptionRenderer optionRenderer()
Returns the IOptionRenderer used to render options to Text before adding this text to the TextTable in this layout.- Since:
- 4.6
-
parameterRenderer
public CommandLine.Help.IParameterRenderer parameterRenderer()
Returns the IParameterRenderer used to render positional params to Text before adding this text to the TextTable in this layout.- Since:
- 4.6
-
-