cmd

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2023 License: MPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BufferedCommand

type BufferedCommand struct {
	Command

	StdoutBuf bytes.Buffer
	StderrBuf bytes.Buffer
}

func NewBufferedCommand

func NewBufferedCommand(cmd string, opts ...CommandOption) *BufferedCommand

type Command

type Command interface {
	Command() string

	// Stdin is an io.Reader for the standard input
	// Stdin is used by the executing System
	Stdin() io.Reader

	// Stdout is an io.Writer for the standard output
	// Stdout is used by the executing System
	Stdout() io.Writer

	// Stderr is an io.Writer for the standard error
	// Stderr is used by the executing System
	Stderr() io.Writer
}

func NewCommand

func NewCommand(cmd string, opts ...CommandOption) Command

func NewCommandWithFunc

func NewCommandWithFunc(cmdFunc func() string, opts ...CommandOption) Command

type CommandOption

type CommandOption func(*command)

func CombinedOutput

func CombinedOutput(out io.Writer) CommandOption

func Passthrough

func Passthrough(parent Command) CommandOption

func Stderr

func Stderr(stderr io.Writer) CommandOption

func Stdin

func Stdin(stdin io.Reader) CommandOption

func Stdout

func Stdout(stdout io.Writer) CommandOption

type Middleware

type Middleware func(Command) Command

Middleware wraps to a command similar to a http middleware.

func ShMiddleware

func ShMiddleware() Middleware

ShMiddleware returns a Middleware which executes a command using the shell /bin/sh

func SudoShMiddleware

func SudoShMiddleware() Middleware

SudoShMiddleware returns a Middleware which executes a command using `sudo`

type Result

type Result interface {
	ExitCode() int
}

func NewResult

func NewResult(exitCode int) Result

Jump to

Keyboard shortcuts

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