Package com.sshtools.client.tasks
Class CommandTask.CommandTaskBuilder
java.lang.Object
com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder<B,TT>
com.sshtools.client.tasks.AbstractSessionTask.AbstractSessionTaskBuilder<CommandTask.CommandTaskBuilder,SessionChannelNG,CommandTask>
com.sshtools.client.tasks.CommandTask.CommandTaskBuilder
- Enclosing class:
- CommandTask
public static final class CommandTask.CommandTaskBuilder
extends AbstractSessionTask.AbstractSessionTaskBuilder<CommandTask.CommandTaskBuilder,SessionChannelNG,CommandTask>
Builder for
CommandTask.-
Field Summary
Fields inherited from class com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder
clientSupplier, connection -
Method Summary
Modifier and TypeMethodDescriptionbuild()create()Create a newCommandTask.CommandTaskBuilder.onBeforeExecute(CommandTask.CommandTaskEvent onBeforeExecute) Set a callback to run before the command is executed.Set a callback to run when the command has been executed.onClose(CommandTask.CommandTaskEvent onClose) Set a callback to run when the command is closed.onTask(CommandTask.CommandTaskEvent onExecute) Set a callback to run when the command has been executed.Set to auto-consume input.withAutoConsume(boolean autoConsume) Set the whether to auto-consume input.withColumns(int cols) Set the terminal width in columns to use when allocating a PTY.withCommand(String command) Set the command to run.withEncoding(String encoding) Set the character encoding to use for transferring string content.withEncoding(Charset encoding) Set the character encoding to use for transferring string content.withModes(PseudoTerminalModes modes) Set the terminal modes to use when allocating a PTY.Do not to allocate a Pty.withPty(boolean withPty) Set whether or not to allocate a Pty.withRows(int rows) Set the terminal height in rows to use when allocating a PTY.withTermType(String termType) Set the terminal type to use when allocating a PTY.withTermType(Optional<String> termType) Set the terminal type to use when allocating a PTY.Methods inherited from class com.sshtools.client.tasks.AbstractSessionTask.AbstractSessionTaskBuilder
withFuture, withSessionMethods inherited from class com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder
withClient, withClients, withConnection
-
Method Details
-
withAutoConsume
Set to auto-consume input. Will be ignored ifAbstractSessionTask.AbstractSessionTaskBuilder.withSession(java.util.function.Function)has been used.- Returns:
- this for chaining
-
withAutoConsume
Set the whether to auto-consume input. Will be ignored ifAbstractSessionTask.AbstractSessionTaskBuilder.withSession(java.util.function.Function)has been used.- Parameters:
autoConsume- auto consume- Returns:
- this for chaining
-
withTermType
Set the terminal type to use when allocating a PTY. Note, this will have no effect if {withPtyis set tofalse.- Parameters:
term- type- Returns:
- builder for chaining
-
withTermType
Set the terminal type to use when allocating a PTY. Note, this will have no effect if {withPtyis set tofalse.- Parameters:
term- type- Returns:
- builder for chaining
-
withColumns
Set the terminal width in columns to use when allocating a PTY. Note, this will have no effect if {withPtyis set tofalse.- Parameters:
cols- cols- Returns:
- builder for chaining
-
withRows
Set the terminal height in rows to use when allocating a PTY. Note, this will have no effect if {withPtyis set tofalse.- Parameters:
rows- row- Returns:
- builder for chaining
-
withModes
Set the terminal modes to use when allocating a PTY. Note, this will have no effect if {withPtyis set tofalse.- Parameters:
modes- modes- Returns:
- builder for chaining
-
withPty
Set whether or not to allocate a Pty. When set totrue, other Pty characteristics can be set using builder methods such aswithRows(int),withModes(PseudoTerminalModes)and others. By default a Pty is allocated.- Parameters:
withPty- whether to allocate a PTY.- Returns:
- builder for chaining
-
withoutPty
Do not to allocate a Pty.- Parameters:
withPty- whether to allocate a PTY.- Returns:
- builder for chaining
-
withCommand
Set the command to run. This is mandatory.- Parameters:
command- command- Returns:
- this for chaining
-
withEncoding
Set the character encoding to use for transferring string content.- Parameters:
encoding- encoding- Returns:
- builder for chaining
-
withEncoding
Set the character encoding to use for transferring string content.- Parameters:
encoding- encoding- Returns:
- builder for chaining
-
create
Create a newCommandTask.CommandTaskBuilder.- Returns:
- builder
-
onBeforeExecute
public final CommandTask.CommandTaskBuilder onBeforeExecute(CommandTask.CommandTaskEvent onBeforeExecute) Set a callback to run before the command is executed.- Parameters:
onBeforeExecute- on before execute callback- Returns:
- builder for chaining
-
onClose
Set a callback to run when the command is closed.- Parameters:
onClose- on close callback- Returns:
- builder for chaining
-
onBeforeTask
Set a callback to run when the command has been executed. This should NOT block until the task is done.- Parameters:
onOpen- on session channel open- Returns:
- builder for chaining
-
onTask
Set a callback to run when the command has been executed. Here you can obtain I/O streams if required, and then block until the task is done. The channel backing this task will be closed when the callback exits. If you do not set this,AbstractSessionTask.close()should be called when the task is finished with.- Parameters:
onExecute- execute task- Returns:
- builder for chaining
-
build
- Specified by:
buildin classAbstractConnectionTask.AbstractConnectionTaskBuilder<CommandTask.CommandTaskBuilder,CommandTask>
-