Skip to main content

Terminal API

The terminal module of the @codebolt/plugin-sdk.

import plugin from '@codebolt/plugin-sdk';

Quick Reference

MethodDescription
eventEmitter
executeCommandExecutes a given command and returns the result.
executeCommandRunUntilErrorExecutes a given command and keeps running until an error occurs.
executeCommandRunUntilInterruptExecutes a given command and keeps running until manually interrupted.
executeCommandWithStreamExecutes a given command and streams the output.
sendManualInterruptSends a manual interrupt signal to the terminal.

Methods


eventEmitter

plugin.terminal.eventEmitter(): void

No parameters.

Returns: void

Full reference →


executeCommand

plugin.terminal.executeCommand(command: string, returnEmptyStringOnSuccess: boolean): Promise<CommandOutput | CommandError | CommandFinish>

Executes a given command and returns the result. Listens for messages from the WebSocket that indicate the output, error, or finish state of the executed command and resolves the promise accordingly.

ParameterTypeRequiredDescription
commandstringYesThe command to be executed.
returnEmptyStringOnSuccessbooleanYes(default: false)

Returns: Promise<CommandOutput | CommandError | CommandFinish> — A promise that resolves with the command's output, error, or finish signal.

Full reference →


executeCommandRunUntilError

plugin.terminal.executeCommandRunUntilError(command: string, executeInMain: boolean): Promise<CommandError>

Executes a given command and keeps running until an error occurs. Listens for messages from the WebSocket and resolves the promise when an error is encountered.

ParameterTypeRequiredDescription
commandstringYesThe command to be executed.
executeInMainbooleanYes(default: false)

Returns: Promise<CommandError> — A promise that resolves when an error occurs during command execution.

Full reference →


executeCommandRunUntilInterrupt

plugin.terminal.executeCommandRunUntilInterrupt(command: string, executeInMain: boolean): Promise<CommandError>

Executes a given command and keeps running until manually interrupted. Listens for messages from the WebSocket and resolves the promise when interrupted.

ParameterTypeRequiredDescription
commandstringYesThe command to be executed.
executeInMainbooleanYesWhether to execute in main terminal. (default: false)

Returns: Promise<CommandError> — A promise that resolves when the command is interrupted.

Full reference →


executeCommandWithStream

plugin.terminal.executeCommandWithStream(command: string, executeInMain: boolean): CustomEventEmitter

Executes a given command and streams the output. Listens for messages from the WebSocket and streams the output data.

ParameterTypeRequiredDescription
commandstringYesThe command to be executed.
executeInMainbooleanYes(default: false)

Returns: CustomEventEmitter — A promise that streams the output data during command execution.

Full reference →


sendManualInterrupt

plugin.terminal.sendManualInterrupt(): Promise<TerminalInterruptResponse>

Sends a manual interrupt signal to the terminal.

No parameters.

Returns: Promise<TerminalInterruptResponse>

Full reference →