Documentation ¶
Index ¶
Constants ¶
const (
MAX_RESULTS = 100
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CommandResult ¶
CommandResult holds the result of a shell command execution.
type ShellRunner ¶
type ShellRunner struct {
// contains filtered or unexported fields
}
ShellRunner manages shell command execution.
func NewShellRunner ¶
func NewShellRunner() *ShellRunner
NewShellRunner creates a new ShellRunner instance with the default shell (`sh`).
func NewShellRunnerWithShell ¶
func NewShellRunnerWithShell(shell string) *ShellRunner
NewShellRunnerWithShell creates a new ShellRunner with the specified shell.
func (*ShellRunner) AddCommand ¶
func (sr *ShellRunner) AddCommand(command string, callback func(*CommandResult)) error
AddCommand adds a shell command to be executed with an optional callback. No commands can be added if the runner has been stopped or not yet started. The callback is executed asynchronously after the command has completed. The order of command execution and callback invocation can be expected to be preserved.
func (*ShellRunner) GetResults ¶
func (sr *ShellRunner) GetResults() *CommandResult
GetResults retrieves the next available command result (non-blocking).
func (*ShellRunner) Kill ¶
func (sr *ShellRunner) Kill()
Kill stops the ShellRunner immediately, terminating all running commands.
func (*ShellRunner) KillWithTimeout ¶
func (sr *ShellRunner) KillWithTimeout(timeout time.Duration) error
KillWithTimeout attempts to stop the ShellRunner, killing commands if the duration is exceeded.
func (*ShellRunner) Start ¶
func (sr *ShellRunner) Start()
Start begins processing shell commands asynchronously.
func (*ShellRunner) Stop ¶
func (sr *ShellRunner) Stop()
Stop gracefully stops the ShellRunner, closing the command queue and waiting for all commands to finish.