Documentation ¶
Index ¶
- type BlockOutput
- type RunResult
- func (x *RunResult) Completed() bool
- func (x *RunResult) Error() error
- func (x *RunResult) FileName() base.FilePath
- func (x *RunResult) HasProgrammerError() bool
- func (x *RunResult) Index() int
- func (x *RunResult) Print(selectedLabel base.Label)
- func (x *RunResult) SetBlock(b *program.BlockPgm) *RunResult
- func (x *RunResult) SetError(e error) *RunResult
- func (x *RunResult) SetFileName(n base.FilePath) *RunResult
- func (x *RunResult) SetIndex(i int) *RunResult
- func (x *RunResult) StdErr() string
- func (x *RunResult) StdOut() string
- type Subshell
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BlockOutput ¶
type BlockOutput struct {
// contains filtered or unexported fields
}
BlockOutput pairs success status (yes or no) with the output collected from a stream (i.e. stderr or stdout) as a result of executing a command block (or as much as could be executed before it failed).
Output can appear on stderr without necessarily being associated with shell failure, so it's collected even in successful runs.
func NewCompleteOutput ¶
func NewCompleteOutput(output string) *BlockOutput
NewCompleteOutput returns a BlockOutput configured to signal completion.
func NewIncompleteOutput ¶
func NewIncompleteOutput(output string) *BlockOutput
NewIncompleteOutput returns a BlockOutput configured to signal incompletion.
func (BlockOutput) Completed ¶
func (x BlockOutput) Completed() bool
Completed is true if the stream was processed without error. Does not mean that the shell completed without error, only means there was no piping problem or unexpected early termination.
func (BlockOutput) Output ¶
func (x BlockOutput) Output() string
Output returns text accumulated from a stream.
type RunResult ¶
type RunResult struct {
// contains filtered or unexported fields
}
RunResult pairs BlockOutput with meta data about shell execution.
func NewRunResult ¶
func NewRunResult(out, err *BlockOutput) *RunResult
NewRunResult is a ctor for RunResult.
func (*RunResult) Completed ¶
Completed means the shell run completed, but implies nothing about exit code.
func (*RunResult) HasProgrammerError ¶
HasProgrammerError is one of those "This should never happen" things.
func (*RunResult) SetFileName ¶
SetFileName sets the filename.
type Subshell ¶
type Subshell struct {
// contains filtered or unexported fields
}
Subshell can run a program
func NewSubshell ¶
NewSubshell returns a shell loaded with a program and block timeout ready to run.
func (*Subshell) Run ¶
Run runs command blocks in a subprocess, stopping and reporting on any error.
Command blocks are strings presumably holding code from some shell language. The strings may be more complex than single commands delimitted by linefeeds - e.g. blocks that operate on HERE documents, or multi-line commands using line continuation via '\', quotes or curly brackets.
This function itself is not a shell interpreter, so it cannot know if one line of text from a command block is an individual command or part of something else.
Error reporting works by discarding output from command blocks that succeeded, and only reporting the contents of stdout and stderr when the subprocess exits on error.