executor

package
v0.0.0-...-2267940 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 9, 2025 License: Apache-2.0, MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Executor

type Executor interface {
	// Execute executes the given command
	Execute(command string, args ...string) ([]byte, error)

	// LookPath searches for an executable named file in the directories named
	// by the PATH environment variable.
	LookPath(file string) (string, error)
}

Executor is an interface for executing commands.

type LocalExecutor

type LocalExecutor struct {
	// contains filtered or unexported fields
}

LocalExecutor is an Executor that runs commands locally.

func NewLocalExecutor

func NewLocalExecutor(logger *slog.Logger, options ...LocalExecutorOption) *LocalExecutor

NewLocalExecutor creates a new LocalExecutor with the given options.

func (*LocalExecutor) Execute

func (e *LocalExecutor) Execute(command string, args ...string) ([]byte, error)

Execute runs a command with the given arguments and returns the combined output.

func (*LocalExecutor) LookPath

func (e *LocalExecutor) LookPath(file string) (string, error)

LookPath searches for an executable named file in the directories named by the PATH environment variable.

type LocalExecutorOption

type LocalExecutorOption func(e *LocalExecutor)

LocalExecutorOption is an option for configuring a LocalExecutor.

func WithColors

func WithColors() LocalExecutorOption

WithColors configures the LocalExecutor to enable colors.

func WithRedirect

func WithRedirect() LocalExecutorOption

WithRedirect configures the LocalExecutor to redirect stdout and stderr to the local process's stdout and stderr while also capturing the output.

func WithRedirectTo

func WithRedirectTo(stdout, stderr io.Writer) LocalExecutorOption

WithRedirectTo configures the LocalExecutor to redirect stdout and stderr to the given writers while also capturing the output.

func WithWorkdir

func WithWorkdir(workdir string) LocalExecutorOption

WithWorkdir configures the LocalExecutor to run commands in the given working directory.

type WrappedExecuter

type WrappedExecuter interface {
	Execute(args ...string) ([]byte, error)
}

WrappedExecuter is an interface for executing commands using a specific command.

type WrappedLocalExecutor

type WrappedLocalExecutor struct {
	Executor
	// contains filtered or unexported fields
}

WrappedLocalExecutor wraps an Executor with a specific command, allowing for easier repeated execution of the same command with different arguments.

func NewWrappedLocalExecutor

func NewWrappedLocalExecutor(e Executor, command string) *WrappedLocalExecutor

NewWrappedLocalExecutor creates a new WrappedLocalExecutor that always executes the specified command using the provided Executor.

func (*WrappedLocalExecutor) Execute

func (e *WrappedLocalExecutor) Execute(args ...string) ([]byte, error)

Execute runs the wrapped command with the given arguments.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL