Started writing documentation and adding examples
This commit is contained in:
parent
7adb09d4db
commit
405bf812ee
5 changed files with 40 additions and 0 deletions
6
exec.go
6
exec.go
|
|
@ -5,10 +5,16 @@ import (
|
|||
"os"
|
||||
)
|
||||
|
||||
// Runnable is a pipeline that can be executed by Run. The *script.Pipe type implements this interface
|
||||
type Runnable interface {
|
||||
// Stdout invokes the runnable task with the result written to stdout, if successful. It returns the number
|
||||
// of bytes written out, or an error if the task was unsuccessful.
|
||||
Stdout() (int, error)
|
||||
}
|
||||
|
||||
// Run takes a number of pipes and executes them in order, until they all succeed or the first error is encountered.
|
||||
// If a runnable task fails with an error, it will write the error to stderr and terminate the program with exit code 1.
|
||||
// It's designed to be used within the "main()" function.
|
||||
func Run(pipes ...Runnable) {
|
||||
for _, pipe := range pipes {
|
||||
if _, err := pipe.Stdout(); err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue