Package: groovy.cli.internal

## [Groovy] Class CliBuilderInternal

- groovy.cli.internal.CliBuilderInternal

- Cut-down version of CliBuilder with just enough functionality for Groovy's internal usage. Uses the embedded version of picocli classes. TODO: prune this right back to have only the functionality needed by Groovy commandline tools

- - ### Properties Summary

    Properties
    Type | Name and description
    --- | ---
    `private boolean` | `acceptLongOptionsWithSingleHyphen` For backwards compatibility with Apache Commons CLI, set this property to `true` if the parser should recognize long options with both a single hyphen and a double hyphen prefix.
    `private PrintWriter` | `errorWriter` The PrintWriter to write to when invalid user input was provided to the parse(java.lang.String[]) method.
    `private boolean` | `expandArgumentFiles` Whether arguments of the form '`@`filename' will be expanded into the arguments contained within the file named filename (default true).
    `private String` | `footer` Optional additional message for usage; displayed after the options.
    `private String` | `header` Optional additional message for usage; displayed after the usage summary but before the options are displayed.
    `private String` | `name` This property allows customizing the program name displayed in the synopsis when `cli.usage()` is called.
    `private ParserSpec` | `parser`
    `private Boolean` | `posix` To disallow clustered POSIX short options, set this to false.
    `private Map` | `savedTypeOptions` Internal data structure mapping option names to their associated TypedOption object.
    `private boolean` | `stopAtNonOption` Configures what the parser should do when arguments not recognized as options are encountered: when `true` (the default), the remaining arguments are all treated as positional parameters.
    `private String` | `usage` The command synopsis displayed as the first line in the usage help message, e.g., when `cli.usage()` is called.
    `private UsageMessageSpec` | `usageMessage`
    `private int` | `width` Allows customisation of the usage message width.
    `private PrintWriter` | `writer` The PrintWriter to write the usage help message to when `cli.usage()` is called.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `CliBuilderInternal ()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `Object` | `invokeMethod(String name, Object args)` Internal method: Detect option specification method calls.
    `<T>` | `TypedOption` | `option(Map args, Class type, String description)`
    `` | `OptionSpec` | `option(Object shortname, Map details, Object description)` Internal method: How to create an OptionSpec from the specification.
    `` | `OptionAccessor` | `parse(Object args)` Make options accessible from command line args with parser.
    `` | `void` | `setExpandArgumentFiles(boolean expand)` Sets the expandArgumentFiles property on this `CliBuilder` and on the parser used by the underlying library.
    `` | `void` | `setFooter(String footer)` Sets the footer property on this `CliBuilder` and on the usageMessage used by the underlying library.
    `` | `void` | `setHeader(String header)` Sets the header property on this `CliBuilder` and the `description` on the usageMessage used by the underlying library.
    `` | `void` | `setPosix(Boolean posix)` Sets the posix property on this `CliBuilder` and the `posixClusteredShortOptionsAllowed` property on the parser used by the underlying library.
    `` | `void` | `setStopAtNonOption(boolean stopAtNonOption)` Sets the stopAtNonOption property on this `CliBuilder` and the `stopAtPositional` property on the parser used by the underlying library.
    `` | `void` | `setUsage(String usage)` Sets the usage property on this `CliBuilder` and the `customSynopsis` on the usageMessage used by the underlying library.
    `` | `void` | `setWidth(int width)` Sets the width property on this `CliBuilder` and on the usageMessage used by the underlying library.
    `` | `void` | `setWriter(PrintWriter writer)` For backwards compatibility reasons, if a custom `writer` is set, this sets both the writer and the errorWriter to the specified writer.
    `` | `void` | `usage()` Prints the usage message with the specified header, footer and width to the specified writer (default: System.out).

  - ### Inherited Methods Summary

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

- - ### Property Detail

    - #### private boolean acceptLongOptionsWithSingleHyphen

      For backwards compatibility with Apache Commons CLI, set this property to `true` if the parser should recognize long options with both a single hyphen and a double hyphen prefix. The default is `false`, so only long options with a double hypen prefix (`--option`) are recognized.

      Since:
        2.5

    - #### private PrintWriter errorWriter

      The PrintWriter to write to when invalid user input was provided to the parse(java.lang.String[]) method. Defaults to stderr but you can provide your own PrintWriter if desired.

      Since:
        2.5

    - #### private boolean expandArgumentFiles

      Whether arguments of the form '`@`filename' will be expanded into the arguments contained within the file named filename (default true).

    - #### private String footer

      Optional additional message for usage; displayed after the options.

    - #### private String header

      Optional additional message for usage; displayed after the usage summary but before the options are displayed.

    - #### private String name

      This property allows customizing the program name displayed in the synopsis when `cli.usage()` is called. Ignored if the usage property is set.

      Since:
        2.5

    - #### private final ParserSpec parser

    - #### private Boolean posix

      To disallow clustered POSIX short options, set this to false.

    - #### private Map savedTypeOptions

      Internal data structure mapping option names to their associated TypedOption object.

    - #### private boolean stopAtNonOption

      Configures what the parser should do when arguments not recognized as options are encountered: when `true` (the default), the remaining arguments are all treated as positional parameters. When `false`, the parser will continue to look for options, and only the unrecognized arguments are treated as positional parameters.

    - #### private String usage

      The command synopsis displayed as the first line in the usage help message, e.g., when `cli.usage()` is called. When not set, a default synopsis is generated that shows the supported options and parameters.

      See Also:
        name

    - #### private final UsageMessageSpec usageMessage

    - #### private int width

      Allows customisation of the usage message width.

    - #### private PrintWriter writer

      The PrintWriter to write the usage help message to when `cli.usage()` is called. Defaults to stdout but you can provide your own PrintWriter if desired.

  - ### Constructor Detail

    - #### CliBuilderInternal()

  - ### Method Detail

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

      Internal method: Detect option specification method calls.

    - #### <T> TypedOption option(Map args, Class type, String description)

    - #### OptionSpec option(Object shortname, Map details, Object description)

      Internal method: How to create an OptionSpec from the specification.

    - #### OptionAccessor parse(Object args)

      Make options accessible from command line args with parser. Returns null on bad command lines after displaying usage message.

    - #### void setExpandArgumentFiles(boolean expand)

      Sets the expandArgumentFiles property on this `CliBuilder` and on the parser used by the underlying library. @-files

      Parameters:
        `expand` - whether to expand argument

    - #### void setFooter(String footer)

      Sets the footer property on this `CliBuilder` and on the usageMessage used by the underlying library.

      Parameters:
        `footer` - the footer of the usage help message

    - #### void setHeader(String header)

      Sets the header property on this `CliBuilder` and the `description` on the usageMessage used by the underlying library.

      Parameters:
        `header` - the description text of the usage help message

    - #### void setPosix(Boolean posix)

      Sets the posix property on this `CliBuilder` and the `posixClusteredShortOptionsAllowed` property on the parser used by the underlying library.

      Parameters:
        `posix` - whether to allow clustered short options

    - #### void setStopAtNonOption(boolean stopAtNonOption)

      Sets the stopAtNonOption property on this `CliBuilder` and the `stopAtPositional` property on the parser used by the underlying library.

      Parameters:
        `stopAtNonOption` - when `true` (the default), the remaining arguments are all treated as positional parameters. When `false`, the parser will continue to look for options, and only the unrecognized arguments are treated as positional parameters.

    - #### void setUsage(String usage)

      Sets the usage property on this `CliBuilder` and the `customSynopsis` on the usageMessage used by the underlying library.

      Parameters:
        `usage` - the custom synopsis of the usage help message

    - #### void setWidth(int width)

      Sets the width property on this `CliBuilder` and on the usageMessage used by the underlying library.

      Parameters:
        `width` - the width of the usage help message

    - #### void setWriter(PrintWriter writer)

      For backwards compatibility reasons, if a custom `writer` is set, this sets both the writer and the errorWriter to the specified writer.

      Parameters:
        `writer` - the writer to initialize both the `writer` and the `errorWriter` to

    - #### void usage()

      Prints the usage message with the specified header, footer and width to the specified writer (default: System.out).