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 java.lang.Object implements CommandLine.Model.IOrdered
TheArgGroupSpecclass models agroupof arguments (options, positional parameters or a mixture of the two).- Since:
- 4.0
- See Also:
CommandLine.ArgGroup
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classCommandLine.Model.ArgGroupSpec.BuilderBuilder responsible for creating validArgGroupSpecobjects.
-
Field Summary
Fields Modifier and Type Field Description private java.util.Set<CommandLine.Model.ArgSpec>args(package private) static intDEFAULT_ORDERprivate booleanexclusiveprivate CommandLine.Model.IGettergetterprivate java.lang.Stringheadingprivate java.lang.StringheadingKeyprivate java.lang.Stringidprivate CommandLine.Model.Messagesmessagesprivate CommandLine.Rangemultiplicityprivate static java.lang.StringNO_HEADINGprivate static java.lang.StringNO_HEADING_KEYprivate intorderprivate CommandLine.Model.ArgGroupSpecparentGroupprivate CommandLine.Model.IScopescopeprivate CommandLine.Model.ISettersetterprivate java.util.List<CommandLine.Model.IAnnotatedElement>specElementsprivate java.util.List<CommandLine.Model.ArgGroupSpec>subgroupsprivate CommandLine.Model.ITypeInfotypeInfoprivate booleanvalidate
-
Constructor Summary
Constructors Constructor Description ArgGroupSpec(CommandLine.Model.ArgGroupSpec.Builder builder)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private java.util.List<CommandLine.Model.OptionSpec>addGroupOptionsToListRecursively(java.util.List<CommandLine.Model.OptionSpec> result)private java.util.List<CommandLine.Model.PositionalParamSpec>addGroupPositionalsToListRecursively(java.util.List<CommandLine.Model.PositionalParamSpec> result)java.util.List<CommandLine.Model.OptionSpec>allOptionsNested()Returns all options configured for this group and all subgroups.java.util.List<CommandLine.Model.PositionalParamSpec>allPositionalParametersNested()Returns all positional parameters configured for this group and all subgroups.(package private) intargCount()java.util.Set<CommandLine.Model.ArgSpec>args()Returns the options and positional parameters in this group; may be empty but notnull.static CommandLine.Model.ArgGroupSpec.Builderbuilder()Returns a newCommandLine.Model.ArgGroupSpec.Builder.static CommandLine.Model.ArgGroupSpec.Builderbuilder(CommandLine.Model.IAnnotatedElement annotatedElement)Returns a newCommandLine.Model.ArgGroupSpec.Builderassociated with the specified annotated element.private CommandLine.Help.Ansi.TextconcatOptionText(java.lang.String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.OptionSpec option)private CommandLine.Help.Ansi.TextconcatPositionalText(java.lang.String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.PositionalParamSpec positionalParam)CommandLine.Help.IParamLabelRenderercreateLabelRenderer(CommandLine.Model.CommandSpec commandSpec)booleanequals(java.lang.Object obj)booleanexclusive()Returns whether this is a mutually exclusive group;trueby default.CommandLine.Model.IGettergetter()Returns theCommandLine.Model.IGetterthat is responsible for supplying the value of the annotated program element associated with this group.inthashCode()java.lang.Stringheading()Returns the heading of this group (may benull), used when generating the usage documentation.java.lang.StringheadingKey()Returns the heading key of this group (may benull), used to get the heading from a resource bundle.(package private) java.lang.Stringid()(package private) voidinitUserObject(CommandLine commandLine)booleanisSubgroupOf(CommandLine.Model.ArgGroupSpec group)Returnstrueif this group is a subgroup (or a nested sub-subgroup, to any level of depth) of the specified group,falseotherwise.(package private) intlocalPositionalParamCount()CommandLine.Model.Messagesmessages()Returns the Messages for this argument group specification, ornull.CommandLine.Model.ArgGroupSpecmessages(CommandLine.Model.Messages msgs)Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec.CommandLine.Rangemultiplicity()Returns the multiplicity of this group: how many occurrences it may have on the command line;"0..1"(optional) by default.java.util.List<CommandLine.Model.OptionSpec>options()Returns the list of options configured for this group.intorder()Returns the position in the options list in the usage help message at which this group should be shown.CommandLine.Model.ArgGroupSpecparentGroup()Returns the parent group that this group is part of, ornullif this group is not part of a composite.java.util.List<CommandLine.Model.PositionalParamSpec>positionalParameters()Returns the list of positional parameters configured for this group.private static java.lang.Stringquote(java.lang.String s)private CommandLine.Help.Ansi.TextrawSynopsisUnitText(CommandLine.Help.ColorScheme colorScheme, java.util.Set<CommandLine.Model.ArgSpec> outparam_groupArgs)java.util.Set<CommandLine.Model.ArgSpec>requiredArgs()Returns the required options and positional parameters in this group; may be empty but notnull.CommandLine.Model.IScopescope()Returns theCommandLine.Model.IScopethat determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.CommandLine.Model.ISettersetter()Returns theCommandLine.Model.ISetterthat is responsible for modifying the value of the annotated program element associated with this group.(package private) voidsetUserObject(java.lang.Object userObject, CommandLine.IFactory factory)java.util.List<CommandLine.Model.IAnnotatedElement>specElements()Returns the list of program elements annotated with{@literal @}Specconfigured for this group.java.util.List<CommandLine.Model.ArgGroupSpec>subgroups()Return the subgroups that this group is composed of; may be empty but notnull.java.lang.Stringsynopsis()Returns the synopsis of this group.CommandLine.Help.Ansi.TextsynopsisText(CommandLine.Help.ColorScheme colorScheme, java.util.Set<CommandLine.Model.ArgSpec> outparam_groupArgs)Returns the synopsis of this group.(package private) java.lang.StringsynopsisUnit()private CommandLine.Help.Ansi.TextsynopsisUnitText(CommandLine.Help.ColorScheme colorScheme, CommandLine.Help.Ansi.Text synopsis)java.lang.StringtoString()(package private) voidtryInitUserObject(CommandLine commandLine)CommandLine.Model.ITypeInfotypeInfo()Returns the type info for the annotated program element associated with this group.(package private) java.lang.ObjectuserObject()(package private) java.lang.ObjectuserObjectOr(java.lang.Object defaultValue)booleanvalidate()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-ocurring group this means that all arguments in the group are specified on the command line.private CommandLine.ParseResult.GroupValidationResultvalidate(CommandLine commandLine, int presentCount, boolean haveMissing, boolean someButNotAllSpecified, java.lang.String exclusiveElements, java.lang.String requiredElements, java.lang.String missingElements)(package private) CommandLine.ParseResult.GroupValidationResultvalidateArgs(CommandLine commandLine, java.util.Collection<CommandLine.Model.ArgSpec> matchedArgs)
-
-
-
Field Detail
-
DEFAULT_ORDER
static final int DEFAULT_ORDER
- See Also:
- Constant Field Values
-
NO_HEADING
private static final java.lang.String NO_HEADING
- See Also:
- Constant Field Values
-
NO_HEADING_KEY
private static final java.lang.String NO_HEADING_KEY
- See Also:
- Constant Field Values
-
heading
private final java.lang.String heading
-
headingKey
private final java.lang.String headingKey
-
exclusive
private final boolean exclusive
-
multiplicity
private final CommandLine.Range multiplicity
-
validate
private final boolean validate
-
order
private final int order
-
getter
private final CommandLine.Model.IGetter getter
-
setter
private final CommandLine.Model.ISetter setter
-
scope
private final CommandLine.Model.IScope scope
-
typeInfo
private final CommandLine.Model.ITypeInfo typeInfo
-
subgroups
private final java.util.List<CommandLine.Model.ArgGroupSpec> subgroups
-
args
private final java.util.Set<CommandLine.Model.ArgSpec> args
-
messages
private CommandLine.Model.Messages messages
-
parentGroup
private CommandLine.Model.ArgGroupSpec parentGroup
-
id
private java.lang.String id
-
specElements
private final java.util.List<CommandLine.Model.IAnnotatedElement> specElements
-
-
Constructor Detail
-
ArgGroupSpec
ArgGroupSpec(CommandLine.Model.ArgGroupSpec.Builder builder)
-
-
Method Detail
-
builder
public static CommandLine.Model.ArgGroupSpec.Builder 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.Builderassociated with the specified annotated element.- Parameters:
annotatedElement- the annotated element containing@Optionand@Parameters- Returns:
- a new ArgGroupSpec.Builder instance
-
exclusive
public boolean exclusive()
Returns whether this is a mutually exclusive group;trueby default. Iffalse, this is a co-occurring group. Ignored ifvalidate()isfalse.- See Also:
CommandLine.ArgGroup.exclusive()
-
multiplicity
public CommandLine.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 ifvalidate()isfalse.- See Also:
CommandLine.ArgGroup.multiplicity()
-
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-ocurring group this means that all arguments in the group are specified on the command line.trueby default.- See Also:
CommandLine.ArgGroup.validate()
-
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 aheadingKeywith a non-nullresource bundle value).- Specified by:
orderin interfaceCommandLine.Model.IOrdered
-
heading
public java.lang.String heading()
Returns the heading of this group (may benull), used when generating the usage documentation.- See Also:
CommandLine.ArgGroup.heading()
-
headingKey
public java.lang.String headingKey()
Returns the heading key of this group (may benull), used to get the heading from a resource bundle.- See Also:
CommandLine.ArgGroup.headingKey()
-
parentGroup
public CommandLine.Model.ArgGroupSpec parentGroup()
Returns the parent group that this group is part of, ornullif this group is not part of a composite.
-
subgroups
public java.util.List<CommandLine.Model.ArgGroupSpec> 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
public java.util.List<CommandLine.Model.IAnnotatedElement> specElements()
Returns the list of program elements annotated with{@literal @}Specconfigured for this group.- Since:
- 4.6
-
isSubgroupOf
public boolean isSubgroupOf(CommandLine.Model.ArgGroupSpec group)
Returnstrueif this group is a subgroup (or a nested sub-subgroup, to any level of depth) of the specified group,falseotherwise.- Parameters:
group- the group to check if it contains this group- Returns:
trueif this group is a subgroup or a nested sub-subgroup of the specified group
-
typeInfo
public CommandLine.Model.ITypeInfo typeInfo()
Returns the type info for the annotated program element associated with this group.- Returns:
- type information that does not require
Classobjects and be constructed both at runtime and compile time
-
getter
public CommandLine.Model.IGetter getter()
Returns theCommandLine.Model.IGetterthat is responsible for supplying the value of the annotated program element associated with this group.
-
setter
public CommandLine.Model.ISetter setter()
Returns theCommandLine.Model.ISetterthat is responsible for modifying the value of the annotated program element associated with this group.
-
scope
public CommandLine.Model.IScope scope()
Returns theCommandLine.Model.IScopethat determines where the setter sets the value (or the getter gets the value) of the annotated program element associated with this group.
-
userObject
java.lang.Object userObject()
-
userObjectOr
java.lang.Object userObjectOr(java.lang.Object defaultValue)
-
id
java.lang.String id()
-
argCount
int argCount()
-
localPositionalParamCount
int localPositionalParamCount()
-
args
public java.util.Set<CommandLine.Model.ArgSpec> args()
Returns the options and positional parameters in this group; may be empty but notnull.
-
requiredArgs
public java.util.Set<CommandLine.Model.ArgSpec> requiredArgs()
Returns the required options and positional parameters in this group; may be empty but notnull.
-
positionalParameters
public java.util.List<CommandLine.Model.PositionalParamSpec> positionalParameters()
Returns the list of positional parameters configured for this group.- Returns:
- an immutable list of positional parameters in this group.
-
options
public java.util.List<CommandLine.Model.OptionSpec> options()
Returns the list of options configured for this group.- Returns:
- an immutable list of options in this group.
-
allOptionsNested
public java.util.List<CommandLine.Model.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
-
addGroupOptionsToListRecursively
private java.util.List<CommandLine.Model.OptionSpec> addGroupOptionsToListRecursively(java.util.List<CommandLine.Model.OptionSpec> result)
-
allPositionalParametersNested
public java.util.List<CommandLine.Model.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
-
addGroupPositionalsToListRecursively
private java.util.List<CommandLine.Model.PositionalParamSpec> addGroupPositionalsToListRecursively(java.util.List<CommandLine.Model.PositionalParamSpec> result)
-
synopsis
public java.lang.String synopsis()
Returns the synopsis of this group.
-
synopsisUnit
java.lang.String synopsisUnit()
-
synopsisText
public CommandLine.Help.Ansi.Text synopsisText(CommandLine.Help.ColorScheme colorScheme, java.util.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, java.util.Set<CommandLine.Model.ArgSpec> outparam_groupArgs)
-
concatOptionText
private CommandLine.Help.Ansi.Text concatOptionText(java.lang.String prefix, CommandLine.Help.Ansi.Text text, CommandLine.Help.ColorScheme colorScheme, CommandLine.Model.OptionSpec option)
-
concatPositionalText
private CommandLine.Help.Ansi.Text concatPositionalText(java.lang.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
public CommandLine.Model.Messages messages()
Returns the Messages for this argument group specification, ornull.
-
messages
public CommandLine.Model.ArgGroupSpec messages(CommandLine.Model.Messages msgs)
Sets the Messages for this ArgGroupSpec, and returns this ArgGroupSpec.- Parameters:
msgs- the new Messages value, may benull- See Also:
CommandLine.Command.resourceBundle(),headingKey()
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
quote
private static java.lang.String quote(java.lang.String s)
-
initUserObject
void initUserObject(CommandLine commandLine)
-
tryInitUserObject
void tryInitUserObject(CommandLine commandLine) throws java.lang.Exception
- Throws:
java.lang.Exception
-
setUserObject
void setUserObject(java.lang.Object userObject, CommandLine.IFactory factory) throws java.lang.Exception- Throws:
java.lang.Exception
-
validateArgs
CommandLine.ParseResult.GroupValidationResult validateArgs(CommandLine commandLine, java.util.Collection<CommandLine.Model.ArgSpec> matchedArgs)
-
validate
private CommandLine.ParseResult.GroupValidationResult validate(CommandLine commandLine, int presentCount, boolean haveMissing, boolean someButNotAllSpecified, java.lang.String exclusiveElements, java.lang.String requiredElements, java.lang.String missingElements)
-
-