command

package
v0.0.0-...-828df2f Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2024 License: MIT Imports: 6 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmder

type Cmder struct{}

Cmder handles running subprograms synchronously and asynchronously.

func NewCmder

func NewCmder() *Cmder

func (*Cmder) Run

func (c *Cmder) Run(cmd ExecCmd) (output string, err error)

Run runs a command in a blocking manner, returning its output and an error if it failed.

func (*Cmder) Start

func (c *Cmder) Start(cmd ExecCmd) (
	stdoutLines, stderrLines chan string, waitError chan error, err error)

Start launches a command and streams stdout and stderr to channels. All the channels returned should be closed when an error, nil or not, is received in the waitError channel. The channels should NOT be closed if an error is returned directly with err, as they will already be closed internally by the function.

type ExecCmd

type ExecCmd interface {
	CombinedOutput() ([]byte, error)
	StdoutPipe() (io.ReadCloser, error)
	StderrPipe() (io.ReadCloser, error)
	Start() error
	Wait() error
}

ExecCmd is the interface for exec.Cmd.

Jump to

Keyboard shortcuts

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