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
Type | Name and description |
---|---|
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. |
PrintWriter |
errorWriter The PrintWriter to write to when invalid user input was provided to the parse(java.lang.String[]) method. |
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.
|
ParserSpec |
parser |
Boolean |
posix To disallow clustered POSIX short options, set this to false. |
Map<String, TypedOption> |
savedTypeOptions Internal data structure mapping option names to their associated TypedOption object. |
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.
|
String |
usage The command synopsis displayed as the first line in the usage help message, e.g., when cli.usage() is called.
|
UsageMessageSpec |
usageMessage |
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.
|
Constructor and description |
---|
CliBuilderInternal
() |
Type Params | Return Type | Name and description |
---|---|---|
|
Object |
invokeMethod(String name, Object args) Internal method: Detect option specification method calls. |
<T> |
TypedOption<T> |
option(Map args, Class<T> 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). |
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.
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.
Whether arguments of the form '@
filename' will be expanded into the arguments contained within the file named filename (default true).
Optional additional message for usage; displayed after the options.
Optional additional message for usage; displayed after the usage summary but before the options are displayed.
This property allows customizing the program name displayed in the synopsis when cli.usage()
is called.
Ignored if the usage property is set.
To disallow clustered POSIX short options, set this to false.
Internal data structure mapping option names to their associated TypedOption object.
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.
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.
Allows customisation of the usage message width.
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.
Internal method: Detect option specification method calls.
Internal method: How to create an OptionSpec from the specification.
Make options accessible from command line args with parser. Returns null on bad command lines after displaying usage message.
Sets the expandArgumentFiles property on this CliBuilder
and on the parser used by the underlying library. @-files
expand
- whether to expand argument Sets the footer property on this CliBuilder
and on the usageMessage used by the underlying library.
footer
- the footer of the usage help message Sets the header property on this CliBuilder
and the
description
on the usageMessage used by the underlying library.
header
- the description text of the usage help message Sets the posix property on this CliBuilder
and the
posixClusteredShortOptionsAllowed
property on the parser
used by the underlying library.
posix
- whether to allow clustered short options Sets the stopAtNonOption property on this CliBuilder
and the
stopAtPositional
property on the parser
used by the underlying library.
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. Sets the usage property on this CliBuilder
and the
customSynopsis
on the usageMessage used by the underlying library.
usage
- the custom synopsis of the usage help message Sets the width property on this CliBuilder
and on the usageMessage used by the underlying library.
width
- the width of the usage help message For backwards compatibility reasons, if a custom writer
is set, this sets
both the writer and the errorWriter to the specified writer.
writer
- the writer to initialize both the writer
and the errorWriter
toCopyright © 2003-2021 The Apache Software Foundation. All rights reserved.