Package picocli

Class CommandLine.Model.ArgSpec

    • Field Detail

      • toString

        protected String toString
    • Method Detail

      • required

        public boolean required()
        Returns whether this is a required option or positional parameter without a default value. If this argument is part of a group, this method returns whether this argument is required within the group (so it is not necessarily a required argument for the command).
        See Also:
        CommandLine.Option.required()
      • interactive

        public boolean interactive()
        Returns whether this option will prompt the user to enter a value on the command line.
        See Also:
        CommandLine.Option.interactive()
      • hideParamSyntax

        public boolean hideParamSyntax()
        Returns whether usage syntax decorations around the paramLabel should be suppressed. The default is false: by default, the paramLabel is surrounded with '[' and ']' characters if the value is optional and followed by ellipses ("...") when multiple values can be specified.
        Since:
        3.6.0
      • auxiliaryTypes

        public Class<?>[] auxiliaryTypes()
        Returns auxiliary type information used when the type() is a generic Collection, Map or an abstract class.
        See Also:
        CommandLine.Option.type()
      • converters

        public CommandLine.ITypeConverter<?>[] converters()
        Returns one or more type converters to use to convert the command line argument into a strongly typed value (or key-value pair for map fields). This is useful when a particular option or positional parameter should use a custom conversion that is different from the normal conversion for the arg spec's type.
        See Also:
        CommandLine.Option.converter()
      • splitRegex

        public String splitRegex()
        Returns a regular expression to split option parameter values or "" if the value should not be split.
        See Also:
        CommandLine.Option.split()
      • hidden

        public boolean hidden()
        Returns whether this option should be excluded from the usage message.
        See Also:
        CommandLine.Option.hidden()
      • type

        public Class<?> type()
        Returns the type to convert the option or positional parameter to before setting the value.
      • typeInfo

        public CommandLine.Model.ITypeInfo typeInfo()
        Returns the ITypeInfo that can be used both at compile time (by annotation processors) and at runtime.
        Since:
        4.0
      • userObject

        public Object userObject()
        Returns the user object associated with this option or positional parameters.
        Returns:
        may return the annotated program element, or some other useful object
        Since:
        4.0
      • defaultValue

        public String defaultValue()
        Returns the default value to assign if this option or positional parameter was not specified on the command line, before splitting and type conversion. This method returns the programmatically set value; this may differ from the default value that is actually used: if this ArgSpec is part of a CommandSpec with a CommandLine.IDefaultValueProvider, picocli will first try to obtain the default value from the default value provider, and this method is only called if the default provider is null or returned a null value.
        Returns:
        the programmatically set default value of this option/positional parameter, returning null means this option or positional parameter does not have a default
        See Also:
        CommandLine.Model.CommandSpec.defaultValueProvider(), CommandLine.Model.OptionSpec.fallbackValue()
      • initialValue

        public Object initialValue()
        Returns the initial value this option or positional parameter. If hasInitialValue() is true, the option will be reset to the initial value before parsing (regardless of whether a default value exists), to clear values that would otherwise remain from parsing previous input.
      • hasInitialValue

        public boolean hasInitialValue()
        Determines whether the option or positional parameter will be reset to the initialValue() before parsing new input.
      • showDefaultValue

        public CommandLine.Help.Visibility showDefaultValue()
        Returns whether this option or positional parameter's default value should be shown in the usage help.
      • defaultValueString

        public String defaultValueString()
        Returns the default value String for the purpose of displaying it in the description, without interpolating variables.
        See Also:
        defaultValueString(boolean)
      • defaultValueString

        public String defaultValueString​(boolean interpolateVariables)
        Returns the default value String displayed in the description; interpolating variables if specified. If this ArgSpec is part of a CommandSpec with a CommandLine.IDefaultValueProvider, this method will first try to obtain the default value from the default value provider; if the provider is null or if it returns a null value, then next any value set to defaultValue() is returned, and if this is also null, finally the initial value is returned.
        Parameters:
        interpolateVariables - whether to interpolate variables in the defaultValue attribute of this ArgSpec
        Since:
        4.0
        See Also:
        CommandLine.Model.CommandSpec.defaultValueProvider(), defaultValue()
      • completionCandidates

        public Iterable<String> completionCandidates()
        Returns the explicitly set completion candidates for this option or positional parameter, valid enum constant names, or null if this option or positional parameter does not have any completion candidates and its type is not an enum.
        Returns:
        the completion candidates for this option or positional parameter, valid enum constant names, or null
        Since:
        3.2
      • parameterConsumer

        public CommandLine.IParameterConsumer parameterConsumer()
        Returns a custom IParameterConsumer to temporarily suspend picocli's parsing logic and process one or more command line arguments in a custom manner, or null. An example of when this may be useful is when passing arguments through to another program.
        Since:
        4.0
      • isMultiValue

        public boolean isMultiValue()
        Returns true if this argument's type() is an array, a Collection or a Map, false otherwise.
      • isOption

        public abstract boolean isOption()
        Returns true if this argument is a named option, false otherwise.
      • isPositional

        public abstract boolean isPositional()
        Returns true if this argument is a positional parameter, false otherwise.
      • group

        public CommandLine.Model.ArgGroupSpec group()
        Returns the groups this option or positional parameter belongs to, or null if this option is not part of a group.
        Since:
        4.0
      • stringValues

        public List<String> stringValues()
        Returns the untyped command line arguments matched by this option or positional parameter spec.
        Returns:
        the matched arguments after splitting, but before type conversion. For map properties, "key=value" values are split into the key and the value part.
      • typedValues

        public List<Object> typedValues()
        Returns the typed command line arguments matched by this option or positional parameter spec.
        Returns:
        the matched arguments after splitting and type conversion. For map properties, "key=value" values are split into the key and the value part.
      • resetStringValues

        protected void resetStringValues()
        Sets the stringValues to a new list instance.
      • originalStringValues

        public List<String> originalStringValues()
        Returns the original command line arguments matched by this option or positional parameter spec.
        Returns:
        the matched arguments as found on the command line: empty Strings for options without value, the values have not been split, and for map properties values may look like "key=value"
      • resetOriginalStringValues

        protected void resetOriginalStringValues()
        Sets the originalStringValues to a new list instance.
      • internalShowDefaultValue

        protected boolean internalShowDefaultValue​(boolean usageHelpShowDefaults)
        Returns whether the default for this option or positional parameter should be shown, potentially overriding the specified global setting.
        Parameters:
        usageHelpShowDefaults - whether the command's UsageMessageSpec is configured to show default values.
      • toString

        public String toString()
        Returns a string respresentation of this option or positional parameter.
        Overrides:
        toString in class Object
      • hashCodeImpl

        protected int hashCodeImpl()