components

package
v0.0.0-...-3b1d31a Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyCommand = errors.New("empty command")
View Source
var ErrInvalidCommand = errors.New("invalid command")

Functions

func Exec

func Exec(ctx context.Context, command string, options contracts.ExecutorOptions) ([]byte, int, error)

func ExecWithWriter

func ExecWithWriter(
	ctx context.Context, command string, out io.Writer, options contracts.ExecutorOptions,
) (int, error)

Types

type CommandHandler

type CommandHandler func(
	ctx context.Context,
	args []string,
	out io.Writer,
	options contracts.ExecutorOptions,
) (int, error)

type CommandsHandlers

type CommandsHandlers map[string]CommandHandler

type Executor

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

func NewCleanExecutor

func NewCleanExecutor() *Executor

NewCleanExecutor returns a new executor. This configuration of executor will not append command and exit code to the output.

func NewExecutor

func NewExecutor() *Executor

NewExecutor returns a new executor. This configuration of executor will append command and exit code to the output.

func (*Executor) Exec

func (e *Executor) Exec(ctx context.Context, command string, options contracts.ExecutorOptions) ([]byte, int, error)

func (*Executor) ExecWithWriter

func (e *Executor) ExecWithWriter(
	ctx context.Context,
	command string,
	out io.Writer,
	options contracts.ExecutorOptions,
) (int, error)

type ExtendableExecutor

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

func NewDefaultExtendableExecutor

func NewDefaultExtendableExecutor(executor contracts.Executor) *ExtendableExecutor

func (*ExtendableExecutor) Exec

func (executor *ExtendableExecutor) Exec(
	ctx context.Context,
	command string,
	options contracts.ExecutorOptions,
) ([]byte, int, error)

func (*ExtendableExecutor) ExecWithWriter

func (executor *ExtendableExecutor) ExecWithWriter(
	ctx context.Context,
	command string,
	out io.Writer,
	options contracts.ExecutorOptions,
) (int, error)

func (*ExtendableExecutor) RegisterHandler

func (executor *ExtendableExecutor) RegisterHandler(command string, handler CommandHandler)

type SafeBuffer

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

SafeBuffer is a goroutine safe bytes.Buffer.

func NewSafeBuffer

func NewSafeBuffer() *SafeBuffer

func (*SafeBuffer) Read

func (s *SafeBuffer) Read(p []byte) (n int, err error)

func (*SafeBuffer) String

func (s *SafeBuffer) String() string

String returns the contents of the unread portion of the buffer as a string. If the buffer is a nil pointer, it returns "<nil>".

func (*SafeBuffer) Write

func (s *SafeBuffer) Write(p []byte) (n int, err error)

Write appends the contents of p to the buffer, growing the buffer as needed. It returns the number of bytes written.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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