Package com.sshtools.client.tasks
Class ShellTask.ShellTaskBuilder
java.lang.Object
com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder<B,TT>
com.sshtools.client.tasks.AbstractSessionTask.AbstractSessionTaskBuilder<ShellTask.ShellTaskBuilder,SessionChannelNG,ShellTask>
com.sshtools.client.tasks.ShellTask.ShellTaskBuilder
- Enclosing class:
- ShellTask
public static final class ShellTask.ShellTaskBuilder
extends AbstractSessionTask.AbstractSessionTaskBuilder<ShellTask.ShellTaskBuilder,SessionChannelNG,ShellTask>
Builder for
ShellTask
.-
Field Summary
Fields inherited from class com.sshtools.client.tasks.AbstractConnectionTask.AbstractConnectionTaskBuilder
clientSupplier, connection
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
static ShellTask.ShellTaskBuilder
create()
Create a newShellTask.ShellTaskBuilder
.onBeforeOpen
(ShellTask.ShellTaskEvent onStartShell) Set a callback to run before the opening of the shell.onBeforeTask
(ShellTask.ShellTaskEvent onBeforeTask) Set a callback to run when the command has been executed.onClose
(ShellTask.ShellTaskEvent onClose) Set a callback to run when the shell is closed.onOpen
(ShellTask.ShellTaskEvent onTask) Deprecated.onTask
(ShellTask.ShellTaskEvent onTask) 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.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, withSession
Methods 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
-
create
Create a newShellTask.ShellTaskBuilder
.- Returns:
- builder
-
withTermType
Set the terminal type to use when allocating a PTY. Note, this will have no effect if {withPty
is 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 {withPty
is 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 {withPty
is 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 {withPty
is 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 {withPty
is set tofalse
.- Parameters:
modes
- modes- Returns:
- builder for chaining
-
onBeforeOpen
Set a callback to run before the opening of the shell. By default, this will allocate a new PTY using the other configuration in this builder, such as terminal type, columns etc. The pty is allocated before this callback is called.- Parameters:
onStartShell
- on start shell callback- Returns:
- builder for chaining
-
onClose
Set a callback to run when the shell is closed.- Parameters:
onBeforeOpen
- on start shell 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:
onBeforeTask
- 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:
onTask
- execute task- Returns:
- builder for chaining
-
onOpen
Deprecated. -
build
- Specified by:
build
in classAbstractConnectionTask.AbstractConnectionTaskBuilder<ShellTask.ShellTaskBuilder,
ShellTask>
-
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
-