com.atlassian.bitbucket.scm.CommandBuilder<B extends com.atlassian.bitbucket.scm.CommandBuilder<B>> |
Known Indirect Subclasses
ScmCommandBuilder<B extends ScmCommandBuilder<B>>
|
Provides a fluent interface for creating free-form commands using arbitrary arguments
.
As this builder is free-form, it is left to the caller to ensure the validity of the command being built. This includes, among other things:
input handler
is supportedMethods for removing property values have two possible prefixes, where each property will only provide one:
About arguments: Each call to a method accepting an argument is expected to be provided a single argument. Providing multiple arguments separated by a space will cause the executed command to fail. Consider the following example:
CommandBuilder<Void> builder = ...;
builder.command("someCommand").argument("a b").build(someOutputHandler).call();
The argument array for the executed command will contain a single entry, "a b"
, not two entries
"a"
and "b"
. This is likely to result in usage exceptions
. This
applies to:
argument(String)
argumentAfter(String, String)
argumentAt(int, String)
argumentBefore(String, String)
rawArgument(String)
rawArgumentAfter(String, String)
rawArgumentAt(int, String)
rawArgumentBefore(String, String)
About whitespace: In general, leading and trailing whitespace for most arguments is usually a mistake, and likely to result in the command failing unexpectedly. When typing commands into a shell, the shell typically consumes leading and trailing whitespace. That behavior is emulated by the following methods:
argument(String)
argumentAfter(String, String)
argumentAt(int, String)
argumentBefore(String, String)
rawArgument(String)
rawArgumentAfter(String, String)
rawArgumentAt(int, String)
rawArgumentBefore(String, String)
Warning: Command builders are not thread-safe. Each builder should be used on a single thread. If multiple threads require builders, each thread should construct its own. Chained builders returned from any method on builder interfaces are attached to their originating build and share threading semantics. This means calling builder methods and passing the returned objects to different threads is also not supported.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Appends the provided argument, with leading and trailing whitespace trimmed
Note: Arguments must be provided one per invocation. | |||||||||||
Inserts the provided argument, with leading and trailing whitespace trimmed, immediately after the
specified anchor if the anchor can be found.
| |||||||||||
Inserts the provided argument, with leading and trailing whitespace trimmed, at the specified index.
| |||||||||||
Inserts the provided argument, with leading and trailing whitespace trimmed, immediately before the
specified anchor if the anchor can be found.
| |||||||||||
Clears any arguments which have been set.
| |||||||||||
Clears the
input handler , if one has been set. | |||||||||||
Applies the default
error handler , which will collect any output written to the
error stream and provide that output to the exit handler . | |||||||||||
Sets the
error handler which will be used to process any output written to the
error stream as the command runs. | |||||||||||
Sets the
input handler which will be used to feed data to the command's input
stream. | |||||||||||
Appends the provided argument, verbatim
Note: Arguments must be provided one per invocation. | |||||||||||
Inserts the provided argument, verbatim, immediately after the specified anchor if the anchor can be
found.
| |||||||||||
Inserts the provided argument, verbatim, at the specified index.
| |||||||||||
Inserts the provided argument, verbatim, immediately before the specified anchor if the anchor can be
found.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From interface
com.atlassian.bitbucket.scm.CommandBuilderSupport
|
Appends the provided argument, with leading and trailing whitespace trimmed
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
argument | the argument to append to the command |
---|
this
IllegalArgumentException | if the provided argument is empty or blank |
---|---|
NullPointerException | if the provided argument is null
|
Inserts the provided argument, with leading and trailing whitespace trimmed, immediately after the specified anchor if the anchor can be found. Otherwise, the argument is appended at the end.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
anchor | the argument serving as the anchor for the new argument |
---|---|
argument | the argument to add immediately after the specified anchor |
this
IllegalArgumentException | if the provided argument is empty or blank |
---|---|
NullPointerException | if the provided argument is null
|
Inserts the provided argument, with leading and trailing whitespace trimmed, at the specified index.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
index | the index at which the argument should be inserted |
---|---|
argument | the argument to insert at the specified index |
this
IllegalArgumentException | if the provided argument is empty or blank |
---|---|
IndexOutOfBoundsException | if the provided index is out of bounds |
NullPointerException | if the provided argument is null
|
Inserts the provided argument, with leading and trailing whitespace trimmed, immediately before the specified anchor if the anchor can be found. Otherwise, the argument is appended at the end.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
anchor | the argument serving as the anchor for the new argument |
---|---|
argument | the argument to add immediately before the specified anchor |
this
IllegalArgumentException | if the provided argument is empty or blank |
---|---|
NullPointerException | if the provided argument is null
|
Clears any arguments which have been set.
this
Clears the input handler
, if one has been set. Without an input handler, no data
will be provided on the command's input stream.
Some commands always read data from their input stream, rather than, or in addition to, considering arguments
provided on the command line. For such commands, the caller must provide an explicit
input handler
; there is no automatic default.
this
Applies the default error handler
, which will collect any output written to the
error stream and provide that output to the exit handler
.
this
Sets the error handler
which will be used to process any output written to the
error stream as the command runs.
When using a custom error handler, the exit handler
will not receive error
stream output; it is assumed that the error handler will have received and processed the output already. If
the error handler throws an exception in response to error stream output, the exit handler will receive that
exception.
value | the handler to receive and process the command's error stream |
---|
this
NullPointerException | if the provided value is null
|
---|
Sets the input handler
which will be used to feed data to the command's input
stream.
Some commands require specific arguments to trigger processing data provided via an input stream. For such commands, the caller must also provide those arguments in addition to setting the input handler; the builder does not add them automatically.
value | the handler to receive and process the command's input stream |
---|
this
NullPointerException | if the provided value is null
|
---|
Appends the provided argument, verbatim
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
argument | the argument to append to the command |
---|
this
NullPointerException | if the provided argument is null |
---|
Inserts the provided argument, verbatim, immediately after the specified anchor if the anchor can be found. Otherwise, the argument is appended at the end.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
anchor | the argument serving as the anchor for the new argument |
---|---|
argument | the argument to add immediately after the specified anchor |
this
NullPointerException | if the provided argument is null |
---|
Inserts the provided argument, verbatim, at the specified index.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
index | the index at which the argument should be inserted |
---|---|
argument | the argument to insert at the specified index |
this
IndexOutOfBoundsException | if the provided index is out of bounds |
---|---|
NullPointerException | if the provided argument is null |
Inserts the provided argument, verbatim, immediately before the specified anchor if the anchor can be found. Otherwise, the argument is appended at the end.
Note: Arguments must be provided one per invocation. There is no need to quote strings which include spaces; spaces in arguments are not interpreted. They are passed as-is to the command.
anchor | the argument serving as the anchor for the new argument |
---|---|
argument | the argument to add immediately before the specified anchor |
this
NullPointerException | if the provided argument is null |
---|