Package io.github.qishr.cascara.common.util
Class Builder
java.lang.Object
io.github.qishr.cascara.common.util.CommandLine.ParseResult.Builder
Enclosing Class:
io.github.qishr.cascara.common.util.CommandLine.ParseResult
public static class Builder
Builds immutable ParseResult instances.
Method Summary
| Modifier and Type | Method | Description |
|---|---|---|
| public ParseResult | build() | Creates and returns a new ParseResult instance for this builder's configuration. |
| public Builder | add(ArgSpec arg, int position) | Adds the specified OptionSpec or PositionalParamSpec to the list of options and parameters that were matched on the command line. |
| public Builder | addOption(OptionSpec option) | Adds the specified OptionSpec to the list of options that were matched on the command line. |
| public Builder | addPositionalParam(PositionalParamSpec positionalParam, int position) | Adds the specified PositionalParamSpec to the list of parameters that were matched on the command line. |
| public Builder | addUnmatched(String arg) | Adds the specified command line argument to the list of unmatched command line arguments. |
| public Builder | addUnmatched(Stack<String> args) | Adds all elements of the specified command line arguments stack to the list of unmatched command line arguments. |
| public Builder | subcommand(ParseResult subcommand) | Sets the specified ParseResult for a subcommand that was matched on the command line. |
| public Builder | originalArgs(String[] originalArgs) | Sets the specified original command line arguments that were passed to the CommandLine#parseArgs(String...) method, before @-file expansion. |
| public Builder | expandedArgs(Collection<String> expandedArgs) | Sets the specified command line arguments after @-files were expanded; these are the arguments that were actually parsed. |
| public void | addError(PicocliException ex) |
Method Details
build
public ParseResult build()
Creates and returns a new ParseResult instance for this builder's configuration.
add
public Builder add(ArgSpec arg, int position)
Adds the specified OptionSpec or PositionalParamSpec to the list of options and parameters
that were matched on the command line.
Parameters:
arg - the matched OptionSpec or PositionalParamSpec
position - the command line position at which the PositionalParamSpec was matched. Ignored for OptionSpecs.
Returns:
this builder for method chaining
addOption
public Builder addOption(OptionSpec option)
Adds the specified OptionSpec to the list of options that were matched on the command line.
addPositionalParam
public Builder addPositionalParam(PositionalParamSpec positionalParam, int position)
Adds the specified PositionalParamSpec to the list of parameters that were matched on the command line.
Parameters:
positionalParam - the matched PositionalParamSpec
position - the command line position at which the PositionalParamSpec was matched.
Returns:
this builder for method chaining
addUnmatched
public Builder addUnmatched(String arg)
Adds the specified command line argument to the list of unmatched command line arguments.
addUnmatched
public Builder addUnmatched(Stack<String> args)
Adds all elements of the specified command line arguments stack to the list of unmatched command line arguments.
subcommand
public Builder subcommand(ParseResult subcommand)
Sets the specified ParseResult for a subcommand that was matched on the command line.
originalArgs
public Builder originalArgs(String[] originalArgs)
Sets the specified original command line arguments that were passed to the CommandLine#parseArgs(String...) method, before @-file expansion.
See Also:
expandedArgs
public Builder expandedArgs(Collection<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:
addError
public void addError(PicocliException ex)