Documentation
¶
Overview ¶
Package tmux provides a thin wrapper around the shared pty.Manager from github.com/chainreactors/utils/pty. It adds aiscan-specific command routing (Command interface, RunCommand, SetCommands, SetWorkDir) and re-exports all base types as aliases for backward compatibility.
Index ¶
- Constants
- Variables
- func SplitCommandLine(input string) ([]string, error)
- type Command
- type Event
- type EventAction
- type Info
- type Manager
- func (m *Manager) RunCommand(cmdLine string, opts RunOpts) (Info, error)
- func (m *Manager) SetCommands(fn func(name string) (Command, bool))
- func (m *Manager) SetExecHooks(before func(w io.Writer), after func())
- func (m *Manager) SetWorkDir(dir string)
- func (m *Manager) Subscribe(fn func(Event)) func()
- type OutputBuffer
- type RunOpts
- type State
- type StdinReceiver
Constants ¶
const ( StateRunning = pty.StateRunning StateCompleted = pty.StateCompleted StateKilled = pty.StateKilled StateFailed = pty.StateFailed )
const ( EventSessionCreated = pty.EventSessionCreated EventSessionUpdated = pty.EventSessionUpdated EventSessionOutput = pty.EventSessionOutput EventSessionClosed = pty.EventSessionClosed )
const ( DefaultTimeout = pty.DefaultTimeout DefaultBufferCap = pty.DefaultBufferCap )
Variables ¶
var ( NewOutputBuffer = pty.NewOutputBuffer NewOutputBufferWithFile = pty.NewOutputBufferWithFile )
Re-export buffer constructors.
var ( ShellCommand = pty.ShellCommand DefaultShellCommand = pty.DefaultShellCommand )
Re-export shell helpers.
var FormatCompletion = pty.FormatCompletion
Re-export formatting.
Functions ¶
func SplitCommandLine ¶
SplitCommandLine splits a command string into tokens, handling quoting and escaping. Comment-only lines (# ...) and blank lines are stripped.
Types ¶
type Command ¶
Command is the minimal interface for an in-process command that can be executed inside a goroutine-based session. The command package's Command interface (which adds Usage()) satisfies this via Go structural subtyping.
type EventAction ¶
type EventAction = pty.EventAction
type Manager ¶
Manager wraps pty.Manager and adds aiscan-specific command routing.
func NewManager ¶
func NewManager() *Manager
NewManager creates a Manager backed by a fresh pty.Manager.
func (*Manager) RunCommand ¶
RunCommand creates a session for the given command line. If the first token matches a registered in-process Command, the command runs in a goroutine-based session (CreateFunc). Otherwise it runs as a shell command in a PTY session (Create).
Pipe support: "pseudo-cmd args | shell-pipeline" is supported. The pseudo-command runs in-process with its output captured to a buffer, then the buffer is piped as stdin to the shell pipeline via sh -c.
func (*Manager) SetCommands ¶
SetCommands injects the lookup function used by RunCommand to detect in-process commands. The function is typically a closure over a CommandRegistry in the calling package.
func (*Manager) SetExecHooks ¶
SetExecHooks sets callbacks invoked before/after each in-process command execution. beforeExec receives the session's io.Writer so the caller can redirect a global output sink; afterExec resets it.
func (*Manager) SetWorkDir ¶
SetWorkDir sets the default working directory for shell sessions created by RunCommand.
type OutputBuffer ¶
type OutputBuffer = pty.OutputBuffer
type RunOpts ¶
type RunOpts struct {
Name string
Timeout time.Duration
WorkDir string
Env []string
Ctx context.Context
}
RunOpts controls how RunCommand creates a session.
type StdinReceiver ¶ added in v0.2.7
type StdinReceiver interface {
SetStdinFile(path string)
}
StdinReceiver is an optional interface for pseudo-commands that can accept piped input. When a "shell | pseudo" pattern is detected, RunCommand writes the shell output to a temp file and calls SetStdinFile before Execute.