Package picocli
Class CommandLine.Model.ArgGroupSpec
java.lang.Object
picocli.CommandLine.Model.ArgGroupSpec
- All Implemented Interfaces:
CommandLine.Model.IOrdered
- Enclosing class:
CommandLine.Model
public static class CommandLine.Model.ArgGroupSpec
extends Object
implements CommandLine.Model.IOrdered
The
ArgGroupSpec
class models a group
of arguments (options, positional parameters or a mixture of the two).- Since:
- 4.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
Builder responsible for creating validArgGroupSpec
objects. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final Set
<CommandLine.Model.ArgSpec> (package private) static final int
private final boolean
private final CommandLine.Model.IGetter
private final String
private final String
private String
private CommandLine.Model.Messages
private final CommandLine.Range
private static final String
private static final String
private final int
private CommandLine.Model.ArgGroupSpec
private final CommandLine.Model.IScope
private final CommandLine.Model.ISetter
private final List
<CommandLine.Model.IAnnotatedElement> private final List
<CommandLine.Model.ArgGroupSpec> private final CommandLine.Model.ITypeInfo
private final boolean
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate List
<CommandLine.Model.OptionSpec> Returns all options configured for this group and all subgroups.Returns all positional parameters configured for this group and all subgroups.(package private) int
argCount()
args()
Returns the options and positional parameters in this group; may be empty but notnull
.builder()
Returns a newCommandLine.Model.ArgGroupSpec.Builder
.builder
(CommandLine.Model.IAnnotatedElement annotatedElement) Returns a newCommandLine.Model.ArgGroupSpec.Builder
associated with the specified annotated element.private CommandLine.Help.Ansi.Text
concatOptionText
(String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.OptionSpec option) private CommandLine.Help.Ansi.Text
concatPositionalText
(String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.PositionalParamSpec positionalParam) createLabelRenderer
(CommandLine.Model.CommandSpec commandSpec) boolean
boolean
Returns whether this is a mutually exclusive group;true
by default.getter()
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of the annotated program element associated with this group.int
hashCode()
heading()
Returns the heading of this group (may benull
), used when generating the usage documentation.Returns the heading key of this group (may benull
), used to get the heading from a resource bundle.(package private) String
id()
(package private) void
initUserObject
(CommandLine commandLine) boolean
Returnstrue
if this group is a subgroup (or a nested sub-subgroup, to any level of depth) of the specified group,false
otherwise.(package private) int
messages()
Returns the Messages for this argument group specification, ornull
.Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec.Returns the multiplicity of this group: how many occurrences it may have on the command line;"0..1"
(optional) by default.options()
Returns the list of options configured for this group.int
order()
Returns the position in the options list in the usage help message at which this group should be shown.Returns the parent group that this group is part of, ornull
if this group is not part of a composite.Returns the list of positional parameters configured for this group.private static String
private CommandLine.Help.Ansi.Text
rawSynopsisUnitText
(CommandLine.Help.ColorScheme colorScheme, Set<CommandLine.Model.ArgSpec> outparam_groupArgs) Returns the required options and positional parameters in this group; may be empty but notnull
.scope()
Returns theCommandLine.Model.IScope
that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.setter()
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of the annotated program element associated with this group.(package private) void
setUserObject
(Object userObject, CommandLine.IFactory factory) Returns the list of program elements annotated with{@literal @}Spec
configured for this group.Return the subgroups that this group is composed of; may be empty but notnull
.synopsis()
Returns the synopsis of this group.synopsisText
(CommandLine.Help.ColorScheme colorScheme, Set<CommandLine.Model.ArgSpec> outparam_groupArgs) Returns the synopsis of this group.(package private) String
private CommandLine.Help.Ansi.Text
synopsisUnitText
(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.Ansi.Text synopsis) toString()
(package private) void
tryInitUserObject
(CommandLine commandLine) typeInfo()
Returns the type info for the annotated program element associated with this group.(package private) Object
(package private) Object
userObjectOr
(Object defaultValue) boolean
validate()
Returns whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.validate
(CommandLine commandLine, int presentCount, boolean haveMissing, boolean someButNotAllSpecified, String exclusiveElements, String requiredElements, String missingElements) (package private) CommandLine.ParseResult.GroupValidationResult
validateArgs
(CommandLine commandLine, Collection<CommandLine.Model.ArgSpec> matchedArgs)
-
Field Details
-
DEFAULT_ORDER
static final int DEFAULT_ORDER- See Also:
-
NO_HEADING
- See Also:
-
NO_HEADING_KEY
- See Also:
-
heading
-
headingKey
-
exclusive
private final boolean exclusive -
multiplicity
-
validate
private final boolean validate -
order
private final int order -
getter
-
setter
-
scope
-
typeInfo
-
subgroups
-
args
-
messages
-
parentGroup
-
id
-
specElements
-
-
Constructor Details
-
ArgGroupSpec
ArgGroupSpec(CommandLine.Model.ArgGroupSpec.Builder builder)
-
-
Method Details
-
builder
Returns a newCommandLine.Model.ArgGroupSpec.Builder
.- Returns:
- a new ArgGroupSpec.Builder instance
-
builder
public static CommandLine.Model.ArgGroupSpec.Builder builder(CommandLine.Model.IAnnotatedElement annotatedElement) Returns a newCommandLine.Model.ArgGroupSpec.Builder
associated with the specified annotated element.- Parameters:
annotatedElement
- the annotated element containing@Option
and@Parameters
- Returns:
- a new ArgGroupSpec.Builder instance
-
exclusive
public boolean exclusive()Returns whether this is a mutually exclusive group;true
by default. Iffalse
, this is a co-occurring group. Ignored ifvalidate()
isfalse
.- See Also:
-
multiplicity
Returns the multiplicity of this group: how many occurrences it may have on the command line;"0..1"
(optional) by default. A group can be made required by specifying a multiplicity of"1"
. For a group of mutually exclusive arguments, being required means that one of the arguments in the group must appear on the command line, or a MissingParameterException is thrown. For a group of co-occurring arguments, being required means that all arguments in the group must appear on the command line. Ignored ifvalidate()
isfalse
.- See Also:
-
validate
public boolean validate()Returns whether picocli should validate the rules of this group: for a mutually exclusive group this means that no more than one arguments in the group is specified on the command line; for a co-occurring group this means that all arguments in the group are specified on the command line.true
by default.- See Also:
-
order
public int order()Returns the position in the options list in the usage help message at which this group should be shown. Groups with a lower number are shown before groups with a higher number. This attribute is only honored for groups that have aheading
(or aheadingKey
with a non-null
resource bundle value).- Specified by:
order
in interfaceCommandLine.Model.IOrdered
-
heading
Returns the heading of this group (may benull
), used when generating the usage documentation.- See Also:
-
headingKey
Returns the heading key of this group (may benull
), used to get the heading from a resource bundle.- See Also:
-
parentGroup
Returns the parent group that this group is part of, ornull
if this group is not part of a composite. -
subgroups
Return the subgroups that this group is composed of; may be empty but notnull
.- Returns:
- immutable list of subgroups that this group is composed of.
-
specElements
Returns the list of program elements annotated with{@literal @}Spec
configured for this group.- Since:
- 4.6
-
isSubgroupOf
Returnstrue
if this group is a subgroup (or a nested sub-subgroup, to any level of depth) of the specified group,false
otherwise.- Parameters:
group
- the group to check if it contains this group- Returns:
true
if this group is a subgroup or a nested sub-subgroup of the specified group
-
typeInfo
Returns the type info for the annotated program element associated with this group.- Returns:
- type information that does not require
Class
objects and be constructed both at runtime and compile time
-
getter
Returns theCommandLine.Model.IGetter
that is responsible for supplying the value of the annotated program element associated with this group. -
setter
Returns theCommandLine.Model.ISetter
that is responsible for modifying the value of the annotated program element associated with this group. -
scope
Returns theCommandLine.Model.IScope
that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group. -
userObject
Object userObject() -
userObjectOr
-
id
String id() -
argCount
int argCount() -
localPositionalParamCount
int localPositionalParamCount() -
args
Returns the options and positional parameters in this group; may be empty but notnull
. -
requiredArgs
Returns the required options and positional parameters in this group; may be empty but notnull
. -
positionalParameters
Returns the list of positional parameters configured for this group.- Returns:
- an immutable list of positional parameters in this group.
-
options
Returns the list of options configured for this group.- Returns:
- an immutable list of options in this group.
-
allOptionsNested
Returns all options configured for this group and all subgroups.- Returns:
- an immutable list of all options in this group and its subgroups.
- Since:
- 4.4
-
addGroupOptionsToListRecursively
private List<CommandLine.Model.OptionSpec> addGroupOptionsToListRecursively(List<CommandLine.Model.OptionSpec> result) -
allPositionalParametersNested
Returns all positional parameters configured for this group and all subgroups.- Returns:
- an immutable list of all positional parameters in this group and its subgroups.
- Since:
- 4.4
-
addGroupPositionalsToListRecursively
private List<CommandLine.Model.PositionalParamSpec> addGroupPositionalsToListRecursively(List<CommandLine.Model.PositionalParamSpec> result) -
synopsis
Returns the synopsis of this group. -
synopsisUnit
String synopsisUnit() -
synopsisText
public CommandLine.Help.Ansi.Text synopsisText(CommandLine.Help.ColorScheme colorScheme, Set<CommandLine.Model.ArgSpec> outparam_groupArgs) Returns the synopsis of this group.- Parameters:
colorScheme
- the color scheme to use for options and positional parameters in this group and subgroupsoutparam_groupArgs
- all options and positional parameters in the groups this method generates a synopsis for; these options and positional parameters should be excluded from appearing elsewhere in the synopsis- Returns:
- the synopsis Text
-
synopsisUnitText
private CommandLine.Help.Ansi.Text synopsisUnitText(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.Ansi.Text synopsis) -
rawSynopsisUnitText
private CommandLine.Help.Ansi.Text rawSynopsisUnitText(CommandLine.Help.ColorScheme colorScheme, Set<CommandLine.Model.ArgSpec> outparam_groupArgs) -
concatOptionText
private CommandLine.Help.Ansi.Text concatOptionText(String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.OptionSpec option) -
concatPositionalText
private CommandLine.Help.Ansi.Text concatPositionalText(String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.PositionalParamSpec positionalParam) -
createLabelRenderer
public CommandLine.Help.IParamLabelRenderer createLabelRenderer(CommandLine.Model.CommandSpec commandSpec) -
messages
Returns the Messages for this argument group specification, ornull
. -
messages
Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec.- Parameters:
msgs
- the new Messages value, may benull
- See Also:
-
equals
-
hashCode
public int hashCode() -
toString
-
quote
-
initUserObject
-
tryInitUserObject
- Throws:
Exception
-
setUserObject
- Throws:
Exception
-
validateArgs
CommandLine.ParseResult.GroupValidationResult validateArgs(CommandLine commandLine, Collection<CommandLine.Model.ArgSpec> matchedArgs) -
validate
private CommandLine.ParseResult.GroupValidationResult validate(CommandLine commandLine, int presentCount, boolean haveMissing, boolean someButNotAllSpecified, String exclusiveElements, String requiredElements, String missingElements)
-