streamexec

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: MIT Imports: 7 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

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

Cmd is a command with a streamline.Stream attached to it.

func Attach

func Attach(cmd *exec.Cmd, mode StreamMode) *Cmd

Run attaches a streamline.Stream to the command, returning a wrapped Cmd that can be configured with pipeline.Pipeline and run with (*Cmd).Run(...).

Output piping is handled by buffers created by streamline/pipe.NewStream(...).

func (*Cmd) Start

func (c *Cmd) Start() (*streamline.Stream, error)

Start starts a command and returns an error if the command fails to start. It also starts a goroutine that waits for command completion and stops the pipe appropriately.

It always returns a valid Stream that can be used to collect output from the underlying command.

func (*Cmd) WithPipeline

func (c *Cmd) WithPipeline(p pipeline.Pipeline) *Cmd

WithPipeline configures Cmd's streamline.Stream with the given pipeline.

type StreamMode

type StreamMode int

StreamMode indicates what output(s) to attach.

const (
	// Combined streams both Stdout and Stderr.
	Combined StreamMode = Stdout | Stderr

	// Stdout only streams cmd.Stdout.
	Stdout StreamMode = 1 << iota
	// Stderr only streams cmd.Stderr.
	Stderr

	// ErrorWithStderr collects Stderr output and includes it in the returned error from
	// Cmd.Start(). Best used with the Stdout StreamMode.
	ErrorWithStderr
)

Jump to

Keyboard shortcuts

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