Documentation
¶
Index ¶
- Constants
- Variables
- func Split(input string) (words []string, err error)
- type CommandGroup
- type CommandPool
- func (cp *CommandPool) Add(sequenceLength int, commandLines ...string) error
- func (cp *CommandPool) Join() (int, error)
- func (cp *CommandPool) NewCommandGroup(cwd string, env []string, stdout, stderr io.Writer, commandLines []string) (*CommandGroup, error)
- func (cp *CommandPool) Start(jobs int) error
- type CommandPoolConfig
- type OutputType
- type SortedOutput
- type SortedOutputWriter
Constants ¶
const ( // OutputStdout corresponds to os.Stdout. OutputStdout = iota // OutputStderr corresponds to os.Stderr. OutputStderr )
Variables ¶
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") )
var DefaultCommandPoolConfig = CommandPoolConfig{ Stderr: os.Stderr, Stdout: os.Stdout, MasterID: -1, }
DefaultCommandPoolConfig is the default command pool configuration.
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
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 ¶
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 SortedOutput ¶
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.