Package io.github.qishr.cascara.common.util
Class ArgGroupSpec
java.lang.Object
io.github.qishr.cascara.common.util.CommandLine.Model.ArgGroupSpec
All Implemented Interfaces:
IOrdered
Enclosing Class:
io.github.qishr.cascara.common.util.CommandLine.Model
public static class ArgGroupSpec
The ArgGroupSpec class models a ArgGroup of arguments (options, positional parameters or a mixture of the two).
Nested Class Summary
| Modifier and Type | Class | Description |
|---|---|---|
| public static | io.github.qishr.cascara.common.util.CommandLine.Model.ArgGroupSpec.Builder | Builder responsible for creating valid ArgGroupSpec objects. |
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public static Builder | builder() | Returns a new Builder. |
| public static Builder | builder(IAnnotatedElement annotatedElement) | Returns a new Builder associated with the specified annotated element. |
| public boolean | exclusive() | Returns whether this is a mutually exclusive group; true by default. |
| public Range | multiplicity() | Returns the multiplicity of this group: how many occurrences it may have on the command line; "0..1" (optional) by default. |
| 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. |
| public int | order() | Returns the position in the options list in the usage help message at which this group should be shown. |
| public String | heading() | Returns the heading of this group (may be null), used when generating the usage documentation. |
| public String | headingKey() | Returns the heading key of this group (may be null), used to get the heading from a resource bundle. |
| public ArgGroupSpec | parentGroup() | Returns the parent group that this group is part of, or null if this group is not part of a composite. |
| public List<ArgGroupSpec> | subgroups() | Return the subgroups that this group is composed of; may be empty but not null. |
| public List<IAnnotatedElement> | specElements() | Returns the list of program elements annotated with {@literal @}Spec configured for this group. |
| public boolean | isSubgroupOf(ArgGroupSpec group) | Returns true if this group is a subgroup (or a nested sub-subgroup, to any level of depth) of the specified group, false otherwise. |
| public ITypeInfo | typeInfo() | Returns the type info for the annotated program element associated with this group. |
| public IGetter | getter() | Returns the IGetter that is responsible for supplying the value of the annotated program element associated with this group. |
| public ISetter | setter() | Returns the ISetter that is responsible for modifying the value of the annotated program element associated with this group. |
| public IScope | scope() | Returns the IScope that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group. |
| public Set<ArgSpec> | args() | Returns the options and positional parameters in this group; may be empty but not null. |
| public Set<ArgSpec> | requiredArgs() | Returns the required options and positional parameters in this group; may be empty but not null. |
| public List<PositionalParamSpec> | positionalParameters() | Returns the list of positional parameters configured for this group. |
| public List<OptionSpec> | options() | Returns the list of options configured for this group. |
| public List<OptionSpec> | allOptionsNested() | Returns all options configured for this group and all subgroups. |
| public List<PositionalParamSpec> | allPositionalParametersNested() | Returns all positional parameters configured for this group and all subgroups. |
| public String | synopsis() | Returns the synopsis of this group. |
| public Text | synopsisText(ColorScheme colorScheme, Set<ArgSpec> outparam_groupArgs) | Returns the synopsis of this group. |
| public IParamLabelRenderer | createLabelRenderer(CommandSpec commandSpec) | |
| public Messages | messages() | Returns the Messages for this argument group specification, or null. |
| public ArgGroupSpec | messages(Messages msgs) | Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec. |
| public boolean | equals(Object obj) | |
| public int | hashCode() | |
| public String | toString() |
Method Details
builder
public static Builder builder()
Returns a new Builder.
Returns:
a new ArgGroupSpec.Builder instance
builder
public static Builder builder(IAnnotatedElement annotatedElement)
Returns a new 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.If false, this is a co-occurring group. Ignored if validate.validate is false.
See Also:
multiplicity
public Range 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 if validate.validate is false.
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 a heading.heading (or a headingKey.headingKey with a non-null resource bundle value).
Specified By:
heading
public String heading()
Returns the heading of this group (may be null), used when generating the usage documentation.
See Also:
headingKey
public String headingKey()
Returns the heading key of this group (may be null), used to get the heading from a resource bundle.
See Also:
parentGroup
public ArgGroupSpec parentGroup()
Returns the parent group that this group is part of, or null if this group is not part of a composite.
subgroups
public List<ArgGroupSpec> subgroups()
Return the subgroups that this group is composed of; may be empty but not null.
Returns:
immutable list of subgroups that this group is composed of.
specElements
public List<IAnnotatedElement> specElements()
Returns the list of program elements annotated with {@literal @}Spec configured for this group.
Since:
4.6
isSubgroupOf
public boolean isSubgroupOf(ArgGroupSpec group)
Returns true 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
public ITypeInfo 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
public IGetter getter()
Returns the IGetter that is responsible for supplying the value of the annotated program element associated with this group.
setter
public ISetter setter()
Returns the ISetter that is responsible for modifying the value of the annotated program element associated with this group.
scope
public IScope scope()
Returns the IScope that determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.
args
Returns the options and positional parameters in this group; may be empty but not null.
requiredArgs
public Set<ArgSpec> requiredArgs()
Returns the required options and positional parameters in this group; may be empty but not null.
positionalParameters
public List<PositionalParamSpec> positionalParameters()
Returns the list of positional parameters configured for this group.
Returns:
an immutable list of positional parameters in this group.
options
public List<OptionSpec> options()
Returns the list of options configured for this group.
Returns:
an immutable list of options in this group.
allOptionsNested
public List<OptionSpec> 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
allPositionalParametersNested
public List<PositionalParamSpec> 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
synopsis
public String synopsis()
Returns the synopsis of this group.
synopsisText
public Text synopsisText(ColorScheme colorScheme, Set<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 subgroups
outparam_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
createLabelRenderer
public IParamLabelRenderer createLabelRenderer(CommandSpec commandSpec)
messages
public Messages messages()
Returns the Messages for this argument group specification, or null.
messages
public ArgGroupSpec messages(Messages msgs)
Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec.
Parameters:
msgs - the new Messages value, may be null
See Also:
equals
public boolean equals(Object obj)
Overrides:
hashCode
public int hashCode()
Overrides:
toString
public String toString()
Overrides: