Documentation
¶
Overview ¶
Package executil provides shell execution utilities.
Index ¶
- type Executor
- type RealExecutor
- func (e *RealExecutor) Run(ctx context.Context, cmd string, args ...string) ([]byte, error)
- func (e *RealExecutor) RunDir(ctx context.Context, dir, cmd string, args ...string) ([]byte, error)
- func (e *RealExecutor) RunDirStream(ctx context.Context, dir string, stdout, stderr io.Writer, cmd string, ...) error
- func (e *RealExecutor) RunStream(ctx context.Context, stdout, stderr io.Writer, cmd string, args ...string) error
- type RecordedCommand
- type RecordingExecutor
- func (e *RecordingExecutor) Reset()
- func (e *RecordingExecutor) Run(ctx context.Context, cmd string, args ...string) ([]byte, error)
- func (e *RecordingExecutor) RunDir(ctx context.Context, dir, cmd string, args ...string) ([]byte, error)
- func (e *RecordingExecutor) RunDirStream(ctx context.Context, dir string, stdout, stderr io.Writer, cmd string, ...) error
- func (e *RecordingExecutor) RunStream(ctx context.Context, stdout, stderr io.Writer, cmd string, args ...string) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor interface {
// Run executes a command and returns its combined output.
Run(ctx context.Context, cmd string, args ...string) ([]byte, error)
// RunDir executes a command in a specific directory.
RunDir(ctx context.Context, dir, cmd string, args ...string) ([]byte, error)
// RunStream executes a command and streams stdout/stderr to the provided writers.
RunStream(ctx context.Context, stdout, stderr io.Writer, cmd string, args ...string) error
// RunDirStream executes a command in a specific directory and streams output.
RunDirStream(ctx context.Context, dir string, stdout, stderr io.Writer, cmd string, args ...string) error
}
Executor runs shell commands.
type RealExecutor ¶
type RealExecutor struct{}
RealExecutor calls actual shell commands.
type RecordedCommand ¶
RecordedCommand captures a command that was executed.
type RecordingExecutor ¶
type RecordingExecutor struct {
Commands []RecordedCommand
// Outputs maps command names to their output.
// Key is the command name (e.g., "git").
Outputs map[string][]byte
// Errors maps command names to their error.
Errors map[string]error
// contains filtered or unexported fields
}
RecordingExecutor captures commands for testing. Configure Outputs and Errors maps to control return values.
func (*RecordingExecutor) Reset ¶
func (e *RecordingExecutor) Reset()
Reset clears recorded commands.
func (*RecordingExecutor) RunDir ¶
func (e *RecordingExecutor) RunDir(ctx context.Context, dir, cmd string, args ...string) ([]byte, error)
RunDir records the command with directory and returns configured output/error.
Click to show internal directories.
Click to hide internal directories.