Package: groovy.cli.commons

## [Groovy] Class OptionAccessor

- groovy.cli.commons.OptionAccessor

-     class OptionAccessor
      extends Object

  Provides typed and dynamic access to parsed command-line options.

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `CommandLine` | `commandLine` The parsed command line.
    `Map<String, TypedOption>` | `savedTypeOptions` Typed option metadata keyed by long name or short name.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `OptionAccessor(CommandLine commandLine)` Creates an accessor for the supplied parsed command line.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `List<String>` | `arguments()` Returns the remaining non-option arguments.
    `<T>` | `T` | `defaultValue(String name)` Returns the converted default value for the named option.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption)` Returns the typed value for the supplied option using subscript syntax.
    `<T>` | `T` | `getAt(TypedOption<T> typedOption, T defaultValue)` Returns the typed value for the supplied option using subscript syntax, falling back to the given default.
    `<T>` | `T` | `getOptionValue(TypedOption<T> typedOption)` Returns the typed value for the supplied option.
    `<T>` | `T` | `getOptionValue(TypedOption<T> typedOption, T defaultValue)` Returns the typed value for the supplied option, falling back to the given default.
    `` | `Object` | `getProperty(String name)` Supports property-style access to option values and flags.
    `` | `boolean` | `hasOption(TypedOption typedOption)` Checks whether the supplied typed option was specified.
    `` | `Object` | `invokeMethod(String name, Object args)` Delegates unknown method calls to the underlying CommandLine.

  - ### Inherited Methods Summary

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

- - ### Property Detail

    - #### CommandLine commandLine

      The parsed command line.

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

      Typed option metadata keyed by long name or short name.

  - ### Constructor Detail

    - #### OptionAccessor(CommandLine commandLine)

      Creates an accessor for the supplied parsed command line.

      Parameters:
        `commandLine` - the parsed command line

  - ### Method Detail

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

      Returns the remaining non-option arguments.

      Returns:
        the remaining arguments

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

      Returns the converted default value for the named option.

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

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

      Returns the typed value for the supplied option using subscript syntax.

      Parameters:
        `typedOption` - the option metadata
      Returns:
        the converted option value, or `null` if the option is absent

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

      Returns the typed value for the supplied option using subscript syntax, falling back to the given default.

      Parameters:
        `typedOption` - the option metadata
        `defaultValue` - the value to return when the option is absent
      Returns:
        the converted option value or `defaultValue`

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

      Returns the typed value for the supplied option.

      Parameters:
        `typedOption` - the option metadata
      Returns:
        the converted option value, or `null` if the option is absent

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

      Returns the typed value for the supplied option, falling back to the given default.

      Parameters:
        `typedOption` - the option metadata
        `defaultValue` - the value to return when the option is absent
      Returns:
        the converted option value or `defaultValue`

    - #### Object getProperty(String name)

      Supports property-style access to option values and flags.

      Parameters:
        `name` - the property name
      Returns:
        the option value, default value, or flag state

    - #### boolean hasOption(TypedOption typedOption)

      Checks whether the supplied typed option was specified.

      Parameters:
        `typedOption` - the option metadata
      Returns:
        `true` if the option is present

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

      Delegates unknown method calls to the underlying CommandLine.

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