Package picocli
Class CommandLine.ParseResult.Builder
- java.lang.Object
-
- picocli.CommandLine.ParseResult.Builder
-
- Enclosing class:
- CommandLine.ParseResult
public static class CommandLine.ParseResult.Builder extends java.lang.Object
Builds immutableParseResult
instances.
-
-
Field Summary
-
Constructor Summary
Constructors Modifier Constructor Description private
Builder(CommandLine.Model.CommandSpec spec)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description CommandLine.ParseResult.Builder
add(CommandLine.Model.ArgSpec arg, int position)
Adds the specifiedOptionSpec
orPositionalParamSpec
to the list of options and parameters that were matched on the command line.void
addError(CommandLine.PicocliException ex)
CommandLine.ParseResult.Builder
addOption(CommandLine.Model.OptionSpec option)
Adds the specifiedOptionSpec
to the list of options that were matched on the command line.(package private) void
addOriginalStringValue(CommandLine.Model.ArgSpec argSpec, java.lang.String value)
CommandLine.ParseResult.Builder
addPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam, int position)
Adds the specifiedPositionalParamSpec
to the list of parameters that were matched on the command line.(package private) void
addStringValue(CommandLine.Model.ArgSpec argSpec, java.lang.String value)
(package private) void
addTypedValues(CommandLine.Model.ArgSpec argSpec, int position, java.lang.Object typedValue)
private CommandLine.ParseResult.Builder
addUnmatched(int position, java.lang.String arg)
Adds the specified command line argument to the list of unmatched command line arguments, and remembers the position of this argument.CommandLine.ParseResult.Builder
addUnmatched(java.lang.String arg)
Adds the specified command line argument to the list of unmatched command line arguments.CommandLine.ParseResult.Builder
addUnmatched(java.util.Stack<java.lang.String> args)
Adds all elements of the specified command line arguments stack to the list of unmatched command line arguments.(package private) void
beforeMatchingGroupElement(CommandLine.Model.ArgSpec argSpec)
CommandLine.ParseResult
build()
Creates and returns a newParseResult
instance for this builder's configuration.CommandLine.ParseResult.Builder
expandedArgs(java.util.Collection<java.lang.String> expandedArgs)
Sets the specified command line arguments after @-files were expanded; these are the arguments that were actually parsed.private void
nowProcessing(CommandLine.Model.ArgSpec spec, java.lang.Object value)
CommandLine.ParseResult.Builder
originalArgs(java.lang.String[] originalArgs)
Sets the specified original command line arguments that were passed to theCommandLine.parseArgs(String...)
method, before @-file expansion.CommandLine.ParseResult.Builder
subcommand(CommandLine.ParseResult subcommand)
Sets the specifiedParseResult
for a subcommand that was matched on the command line.private int
totalArgCount()
-
-
-
Field Detail
-
commandSpec
private final CommandLine.Model.CommandSpec commandSpec
-
matchedArgsList
private final java.util.List<CommandLine.Model.ArgSpec> matchedArgsList
-
matchedOptionsList
private final java.util.List<CommandLine.Model.OptionSpec> matchedOptionsList
-
matchedPositionalsList
private final java.util.List<CommandLine.Model.PositionalParamSpec> matchedPositionalsList
-
options
private final java.util.Set<CommandLine.Model.OptionSpec> options
-
positionals
private final java.util.Set<CommandLine.Model.PositionalParamSpec> positionals
-
unmatched
private final java.util.List<java.lang.String> unmatched
-
firstUnmatchedPosition
private int firstUnmatchedPosition
-
originalArgList
private final java.util.List<java.lang.String> originalArgList
-
expandedArgList
private final java.util.List<java.lang.String> expandedArgList
-
positionalParams
private final java.util.List<java.util.List<CommandLine.Model.PositionalParamSpec>> positionalParams
-
subcommands
private final java.util.List<CommandLine.ParseResult> subcommands
-
usageHelpRequested
private boolean usageHelpRequested
-
versionHelpRequested
private boolean versionHelpRequested
-
isInitializingDefaultValues
boolean isInitializingDefaultValues
-
errors
private final java.util.List<java.lang.Exception> errors
-
nowProcessing
private java.util.List<java.lang.Object> nowProcessing
-
groupMatchContainer
private final CommandLine.ParseResult.GroupMatchContainer groupMatchContainer
-
-
Constructor Detail
-
Builder
private Builder(CommandLine.Model.CommandSpec spec)
-
-
Method Detail
-
build
public CommandLine.ParseResult build()
Creates and returns a newParseResult
instance for this builder's configuration.
-
nowProcessing
private void nowProcessing(CommandLine.Model.ArgSpec spec, java.lang.Object value)
-
add
public CommandLine.ParseResult.Builder add(CommandLine.Model.ArgSpec arg, int position)
Adds the specifiedOptionSpec
orPositionalParamSpec
to the list of options and parameters that were matched on the command line.- Parameters:
arg
- the matchedOptionSpec
orPositionalParamSpec
position
- the command line position at which thePositionalParamSpec
was matched. Ignored forOptionSpec
s.- Returns:
- this builder for method chaining
-
addOption
public CommandLine.ParseResult.Builder addOption(CommandLine.Model.OptionSpec option)
Adds the specifiedOptionSpec
to the list of options that were matched on the command line.
-
addPositionalParam
public CommandLine.ParseResult.Builder addPositionalParam(CommandLine.Model.PositionalParamSpec positionalParam, int position)
Adds the specifiedPositionalParamSpec
to the list of parameters that were matched on the command line.- Parameters:
positionalParam
- the matchedPositionalParamSpec
position
- the command line position at which thePositionalParamSpec
was matched.- Returns:
- this builder for method chaining
-
addUnmatched
private CommandLine.ParseResult.Builder addUnmatched(int position, java.lang.String arg)
Adds the specified command line argument to the list of unmatched command line arguments, and remembers the position of this argument. This position is used in the UnmatchedArgumentException message.- Since:
- 4.6
-
addUnmatched
public CommandLine.ParseResult.Builder addUnmatched(java.lang.String arg)
Adds the specified command line argument to the list of unmatched command line arguments.
-
addUnmatched
public CommandLine.ParseResult.Builder addUnmatched(java.util.Stack<java.lang.String> args)
Adds all elements of the specified command line arguments stack to the list of unmatched command line arguments.
-
totalArgCount
private int totalArgCount()
-
subcommand
public CommandLine.ParseResult.Builder subcommand(CommandLine.ParseResult subcommand)
Sets the specifiedParseResult
for a subcommand that was matched on the command line.
-
originalArgs
public CommandLine.ParseResult.Builder originalArgs(java.lang.String[] originalArgs)
Sets the specified original command line arguments that were passed to theCommandLine.parseArgs(String...)
method, before @-file expansion.
-
expandedArgs
public CommandLine.ParseResult.Builder expandedArgs(java.util.Collection<java.lang.String> expandedArgs)
Sets the specified command line arguments after @-files were expanded; these are the arguments that were actually parsed.- Since:
- 4.4
- See Also:
originalArgs(String[])
,CommandLine.ParseResult.expandedArgs()
-
addStringValue
void addStringValue(CommandLine.Model.ArgSpec argSpec, java.lang.String value)
-
addOriginalStringValue
void addOriginalStringValue(CommandLine.Model.ArgSpec argSpec, java.lang.String value)
-
addTypedValues
void addTypedValues(CommandLine.Model.ArgSpec argSpec, int position, java.lang.Object typedValue)
-
addError
public void addError(CommandLine.PicocliException ex)
-
beforeMatchingGroupElement
void beforeMatchingGroupElement(CommandLine.Model.ArgSpec argSpec) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-