JavaScript is disabled on your browser.
Package: groovy.cli.internal

[Groovy] Class CliBuilderInternal


  • class CliBuilderInternal
    extends Object 

    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

    • Property Detail

      • 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 hyphen prefix (--option) are recognized.

        Since:
        2.5

      • 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

      • boolean expandArgumentFiles

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

      • String footer

        Optional additional message for usage; displayed after the options.

      • String header

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

      • 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

      • Boolean posix

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

      • 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.

      • 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

      • int width

        Allows customisation of the usage message width.

      • 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.

      • 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).

Copyright © 2003-2025 The Apache Software Foundation. All rights reserved.

AltStyle によって変換されたページ (->オリジナル) /