Package: groovy.cli.picocli

## [Groovy] Class OptionAccessor

- groovy.cli.picocli.OptionAccessor

-     class OptionAccessor
      extends Object

  Provides typed and dynamic access to values produced by CliBuilder.parse.

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `ParseResult` | `parseResult` The underlying picocli parse result.
    `Map<String, TypedOption>` | `savedTypeOptions` Type metadata for options declared by the originating CliBuilder.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `OptionAccessor(ParseResult parseResult)` Creates an accessor for the specified parse result.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `List<String>` | `arguments()` Returns the remaining positional arguments.
    `<T>` | `T` | `defaultValue(String name)` Returns the converted default value for a named option.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption)` Returns the value of the specified typed option using subscript syntax.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption, T defaultValue)` Returns the value of the specified typed option using subscript syntax.
    `` | `Properties` | `getOptionProperties(String name)` Returns properties collected for a map-style option.
    `<T>` | `T` | `getOptionValue(TypedOption<T> typedOption)` Returns the value of the specified typed option.
    `<T>` | `T` | `getOptionValue(TypedOption<T> typedOption, T defaultValue)` Returns the value of the specified typed option.
    `` | `Object` | `getProperty(String name)` Resolves dynamic property lookups to parsed option values, defaults, or multi-value views.
    `` | `boolean` | `hasOption(TypedOption typedOption)` Checks whether the specified typed option was matched.
    `` | `Object` | `invokeMethod(String name, Object args)` Provides limited Apache Commons CLI compatibility by delegating selected method calls to the underlying parse result.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Property Detail

    - #### ParseResult parseResult

      The underlying picocli parse result.

    - #### Map<String, TypedOption> savedTypeOptions

      Type metadata for options declared by the originating CliBuilder.

  - ### Constructor Detail

    - #### OptionAccessor(ParseResult parseResult)

      Creates an accessor for the specified parse result.

      Parameters:
        `parseResult` - the parsed command line state

  - ### Method Detail

    - #### List<String> arguments()

      Returns the remaining positional arguments.

      Returns:
        the unmatched positional arguments in encounter order

    - #### <T> T defaultValue(String name)

      Returns the converted default value for a named option.

      Parameters:
        `name` - the option name used to register the option metadata
      Returns:
        the converted default value, or `null` if none was declared

    - #### <T> T getAt(TypedOption<T> typedOption)

      Returns the value of the specified typed option using subscript syntax.

      Parameters:
        `typedOption` - the option to inspect
      Returns:
        the parsed or configured value, or `null` if none is available

    - #### <T> T getAt(TypedOption<T> typedOption, T defaultValue)

      Returns the value of the specified typed option using subscript syntax.

      Parameters:
        `typedOption` - the option to inspect
        `defaultValue` - the fallback value to use when the option has no value
      Returns:
        the parsed value, configured default, or supplied fallback

    - #### Properties getOptionProperties(String name)

      Returns properties collected for a map-style option.

      Parameters:
        `name` - the option name
      Returns:
        the parsed properties, or `null` if the option was not matched

    - #### <T> T getOptionValue(TypedOption<T> typedOption)

      Returns the value of the specified typed option.

      Parameters:
        `typedOption` - the option to inspect
      Returns:
        the parsed or configured value, or `null` if none is available

    - #### <T> T getOptionValue(TypedOption<T> typedOption, T defaultValue)

      Returns the value of the specified typed option.

      Parameters:
        `typedOption` - the option to inspect
        `defaultValue` - the fallback value to use when the option has no value
      Returns:
        the parsed value, configured default, or supplied fallback

    - #### Object getProperty(String name)

      Resolves dynamic property lookups to parsed option values, defaults, or multi-value views.

      Parameters:
        `name` - the property name to resolve
      Returns:
        the resolved value, or `false` when no matching option exists

    - #### boolean hasOption(TypedOption typedOption)

      Checks whether the specified typed option was matched.

      Parameters:
        `typedOption` - the option to inspect
      Returns:
        `true` if the option was supplied on the command line

    - #### Object invokeMethod(String name, Object args)

      Provides limited Apache Commons CLI compatibility by delegating selected method calls to the underlying parse result.

      Parameters:
        `name` - the method name to invoke
        `args` - the method arguments
      Returns:
        the delegated call result