Class CommandLine.Help.Layout
- java.lang.Object
-
- org.apache.logging.log4j.core.tools.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(Field, 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)
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addOption(Field field, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
Delegates to theoption renderer
of this layout to obtain text values for the specifiedCommandLine.Option
, and then calls thelayout(Field, CommandLine.Help.Ansi.Text[][])
method to write these text values into the correct cells in the TextTable.void
addOptions(List<Field> fields, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddOption(Field, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Options in the list.void
addPositionalParameter(Field field, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
Delegates to theparameter renderer
of this layout to obtain text values for the specifiedCommandLine.Parameters
, and then callslayout(Field, CommandLine.Help.Ansi.Text[][])
to write these text values into the correct cells in the TextTable.void
addPositionalParameters(List<Field> fields, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddPositionalParameter(Field, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Parameters in the list.void
layout(Field field, CommandLine.Help.Ansi.Text[][] cellValues)
Copies the specified text values into the correct cells in theCommandLine.Help.TextTable
.String
toString()
Returns the section of the usage help message accumulated in the TextTable owned by this layout.
-
-
-
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)
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(Field field, 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:
field
- the field annotated with the specified Option or ParameterscellValues
- the text values representing the Option/Parameters, to be displayed in tabular form
-
addOptions
public void addOptions(List<Field> fields, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddOption(Field, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Options in the list.- Parameters:
fields
- fields annotated withCommandLine.Option
to add usage descriptions forparamLabelRenderer
- object that knows how to render option parameters
-
addOption
public void addOption(Field field, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
Delegates to theoption renderer
of this layout to obtain text values for the specifiedCommandLine.Option
, and then calls thelayout(Field, CommandLine.Help.Ansi.Text[][])
method to write these text values into the correct cells in the TextTable.- Parameters:
field
- the field annotated with the specified OptionparamLabelRenderer
- knows how to render option parameters
-
addPositionalParameters
public void addPositionalParameters(List<Field> fields, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
CallsaddPositionalParameter(Field, CommandLine.Help.IParamLabelRenderer)
for all non-hidden Parameters in the list.- Parameters:
fields
- fields annotated withCommandLine.Parameters
to add usage descriptions forparamLabelRenderer
- knows how to render option parameters
-
addPositionalParameter
public void addPositionalParameter(Field field, CommandLine.Help.IParamLabelRenderer paramLabelRenderer)
Delegates to theparameter renderer
of this layout to obtain text values for the specifiedCommandLine.Parameters
, and then callslayout(Field, CommandLine.Help.Ansi.Text[][])
to write these text values into the correct cells in the TextTable.- Parameters:
field
- the field annotated with the specified ParametersparamLabelRenderer
- knows how to render option parameters
-
-