cosh

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2020 License: GPL-2.0 Imports: 10 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// OutputStdout corresponds to os.Stdout.
	OutputStdout = iota
	// OutputStderr corresponds to os.Stderr.
	OutputStderr
)

Variables

View Source
var (
	// ErrUnterminatedSingleQuote is returned when a single-quoted string is unterminated.
	ErrUnterminatedSingleQuote = errors.New("Unterminated single-quoted string")
	// ErrUnterminatedDoubleQuote is returned when a double-quoted string is unterminated.
	ErrUnterminatedDoubleQuote = errors.New("Unterminated double-quoted string")
	// ErrUnterminatedEscape is returned when an escape sequence is unterminated.
	ErrUnterminatedEscape = errors.New("Unterminated backslash-escape")
)
View Source
var DefaultCommandPoolConfig = CommandPoolConfig{
	Stderr:   os.Stderr,
	Stdout:   os.Stdout,
	MasterID: -1,
}

DefaultCommandPoolConfig is the default command pool configuration.

View Source
var ErrEmptyCommandLine = errors.New("empty command line")

ErrEmptyCommandLine is returned when an empty command line is specified.

Functions

func Split added in v0.2.1

func Split(input string) (words []string, err error)

Split splits a string according to /bin/sh's word-splitting rules. It supports backslash-escapes, single-quotes, and double-quotes. Notably it does not support the $” style of quoting. It also doesn't attempt to perform any other sort of expansion, including brace expansion, shell expansion, or pathname expansion.

If the given input has an unterminated quoted string or ends in a backslash-escape, one of UnterminatedSingleQuoteError, ErrUnterminatedDoubleQuote, or ErrUnterminatedEscape is returned.

This function is from https://github.com/kballard/go-shellquote under MIT license

Types

type CommandGroup

type CommandGroup struct {
	sync.Mutex
	// contains filtered or unexported fields
}

CommandGroup is a group of commands.

func (*CommandGroup) Run added in v0.2.4

func (cg *CommandGroup) Run() (int, error)

Run will synchronously run all the commands of the command group.

type CommandPool added in v0.2.4

type CommandPool struct {
	CommandPoolConfig
	// contains filtered or unexported fields
}

CommandPool is a command pool with associated configuration and state.

func NewCommandPool added in v0.2.4

func NewCommandPool(cfg *CommandPoolConfig) *CommandPool

NewCommandPool constructs a new CommandPool; configuration is initialized to DefaultCommandPoolConfig if nil.

func (*CommandPool) Add added in v0.2.4

func (cp *CommandPool) Add(sequenceLength int, commandLines ...string) error

Add will add the specified command lines grouped by sequence length. Each group will run sequentially and require that the previous command is successful.

func (*CommandPool) Join added in v0.2.4

func (cp *CommandPool) Join() (int, error)

Join waits for all command groups to complete execution and return the (unsigned) sum of each individual exit code.

func (*CommandPool) NewCommandGroup added in v0.2.4

func (cp *CommandPool) NewCommandGroup(cwd string, env []string, stdout, stderr io.Writer, commandLines []string) (*CommandGroup, error)

NewCommandGroup constructs a new CommandGroup; stdin is not attached to commands.

func (*CommandPool) Start added in v0.2.4

func (cp *CommandPool) Start(jobs int) error

Start will start all command groups concurrently.

type CommandPoolConfig added in v0.2.4

type CommandPoolConfig struct {
	Deinterlace bool
	Halt        bool
	MasterID    int
	ShellArgs   []string
	Stdout      io.Writer
	Stderr      io.Writer
}

CommandPoolConfig is the configuration for a command pool.

type OutputType

type OutputType int

OutputType is the type of output.

type SortedOutput

type SortedOutput struct {
	sync.Mutex
	// contains filtered or unexported fields
}

SortedOutput contains state to replay output segments in the same order they were received in.

func NewSortedOutput

func NewSortedOutput(stdout, stderr io.Writer) *SortedOutput

NewSortedOutput constructs a new SortedOutput.

func (*SortedOutput) ReplayOutputs

func (so *SortedOutput) ReplayOutputs() error

ReplayOutputs will replay all stdout/stderr outputs to parent stdout/stderr.

type SortedOutputWriter

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

SortedOutputWriter is a writer for sorted output.

func (SortedOutputWriter) Write

func (sow SortedOutputWriter) Write(p []byte) (n int, err error)

Jump to

Keyboard shortcuts

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