Package: groovy.cli.internal

## [Groovy] Class OptionAccessor

- groovy.cli.internal.OptionAccessor

-     class OptionAccessor
      extends Object

  Provides typed access to parsed command line options.

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `ParseResult` | `parseResult` The underlying parse result.
    `Map<String, TypedOption>` | `savedTypeOptions` Typed option metadata keyed by option name.

  - ### Constructor Summary

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

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `List<String>` | `arguments()` Returns the unmatched positional arguments.
    `<T>` | `T` | `defaultValue(String name)` Returns the typed default value for the named option.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption)` Returns the value of the specified typed option using subscript notation semantics.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption, T defaultValue)` Returns the value of the specified typed option using subscript notation semantics.
    `` | `Properties` | `getOptionProperties(String name)` Returns key/value pairs for the named option as Properties.
    `<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, falling back to the supplied default.
    `` | `Object` | `getProperty(String name)` Resolves dynamic property access against matched or defaulted options.
    `` | `boolean` | `hasOption(TypedOption typedOption)` Checks whether the specified option was matched.
    `` | `Object` | `invokeMethod(String name, Object args)` Delegates selected dynamic 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 parse result.

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

      Typed option metadata keyed by option name.

  - ### Constructor Detail

    - #### OptionAccessor(ParseResult parseResult)

      Creates an accessor backed by the specified parse result.

      Parameters:
        `parseResult` - the parse result to wrap

  - ### Method Detail

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

      Returns the unmatched positional arguments.

      Returns:
        the positional arguments

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

      Returns the typed default value for the named option.

      Parameters:
        `name` - the option name
      Returns:
        the converted default value, or `null` if none exists

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

      Returns the value of the specified typed option using subscript notation semantics.

      Parameters:
        `typedOption` - the option to retrieve
      Returns:
        the option value, or `null` if not matched

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

      Returns the value of the specified typed option using subscript notation semantics.

      Parameters:
        `typedOption` - the option to retrieve
        `defaultValue` - the fallback value
      Returns:
        the option value or the fallback

    - #### Properties getOptionProperties(String name)

      Returns key/value pairs for the named option as Properties.

      Parameters:
        `name` - the option name
      Returns:
        the option 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 retrieve
      Returns:
        the option value, or `null` if not matched

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

      Returns the value of the specified typed option, falling back to the supplied default.

      Parameters:
        `typedOption` - the option to retrieve
        `defaultValue` - the fallback value
      Returns:
        the option value or the fallback

    - #### Object getProperty(String name)

      Resolves dynamic property access against matched or defaulted options.

      Parameters:
        `name` - the property name
      Returns:
        the resolved option value, or `false` if unavailable

    - #### boolean hasOption(TypedOption typedOption)

      Checks whether the specified option was matched.

      Parameters:
        `typedOption` - the option to check
      Returns:
        `true` if the option was matched

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

      Delegates selected dynamic method calls to the underlying parse result.

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