exec

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound      = errors.New("command not found")
	ErrNotExecutable = errors.New("command not executable")
	ErrInvalidArgs   = errors.New("invalid arguments in command")
)

Functions

func StatusError

func StatusError(err error) error

Types

type Executor

type Executor interface {
	Execute(ctx context.Context, reader io.Reader) (Result, error)
	LastResult() Result
}

type Option

type Option func(*ShellScriptExecutor)

func WithDebug

func WithDebug(debug bool) Option

func WithDryRun

func WithDryRun(dryRun bool) Option

func WithTimeout

func WithTimeout(t time.Duration) Option

type Result

type Result struct {
	Output string
	Status *Status
	DryRun bool
}

type ShellScriptExecutor

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

func NewExecutor

func NewExecutor(options ...Option) *ShellScriptExecutor

func (*ShellScriptExecutor) Execute

func (e *ShellScriptExecutor) Execute(ctx context.Context, src io.Reader) (Result, error)

func (*ShellScriptExecutor) LastResult

func (e *ShellScriptExecutor) LastResult() Result

type Status

type Status struct {
	ScriptName string
	ScriptBody string
	Output     string
	PID        int
	Done       bool
	CPUTime    time.Duration
	ExitCode   int
	Error      error
}

func (*Status) Sprintf

func (s *Status) Sprintf(msg string) string

Directories

Path Synopsis
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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