Documentation
¶
Overview ¶
Package command provides an abstraction over exec.Command for testability.
Index ¶
- type Executor
- type RealExecutor
- func (*RealExecutor) Output(ctx context.Context, name string, args ...string) ([]byte, error)
- func (*RealExecutor) Run(ctx context.Context, name string, args ...string) error
- func (*RealExecutor) Start(ctx context.Context, name string, args ...string) error
- func (*RealExecutor) StartWithOptions(ctx context.Context, _ StartOptions, name string, args ...string) error
- type StartOptions
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 waits for it to complete.
// Returns an error if the command fails to start or exits with non-zero status.
Run(ctx context.Context, name string, args ...string) error
// Output runs a command and returns its standard output.
// Returns the output bytes and an error if the command fails.
Output(ctx context.Context, name string, args ...string) ([]byte, error)
// Start starts a command without waiting for it to complete (fire-and-forget).
// Returns an error if the command fails to start.
Start(ctx context.Context, name string, args ...string) error
// StartWithOptions starts a command with platform-specific options.
// Returns an error if the command fails to start.
StartWithOptions(ctx context.Context, opts StartOptions, name string, args ...string) error
}
Executor provides an abstraction over exec.Command for testability. This allows commands to be mocked in tests without executing real system commands.
type RealExecutor ¶
type RealExecutor struct{}
RealExecutor uses actual exec.Command to execute system commands. This is the production implementation used in normal operation.
func (*RealExecutor) StartWithOptions ¶
func (*RealExecutor) StartWithOptions( ctx context.Context, _ StartOptions, name string, args ...string, ) error
StartWithOptions starts a command with platform-specific options on Unix. HideWindow option is ignored on non-Windows platforms.
type StartOptions ¶
type StartOptions struct {
// HideWindow prevents a console window from appearing (Windows-only).
// On non-Windows platforms, this field is ignored.
HideWindow bool
}
StartOptions configures command startup behavior.
Click to show internal directories.
Click to hide internal directories.