script

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Args = script.Args

Args creates a pipe containing the program's command-line arguments, one per line.

View Source
var Echo = script.Echo

Echo returns a pipe containing the supplied string.

View Source
var File = script.File

File returns a *Pipe associated with the specified file. This is useful for starting pipelines. If there is an error opening the file, the pipe's error status will be set.

View Source
var FindFiles = script.FindFiles

FindFiles takes a directory path and returns a pipe listing all the files in the directory and its subdirectories recursively, one per line, like Unix `find -type f`. If the path doesn't exist or can't be read, the pipe's error status will be set.

View Source
var IfExists = script.IfExists

IfExists tests whether the specified file exists, and creates a pipe whose error status reflects the result. If the file doesn't exist, the pipe's error status will be set, and if the file does exist, the pipe will have no error status. This can be used to do some operation only if a given file exists:

IfExists("/foo/bar").Exec("/usr/bin/something")

View Source
var ListFiles = script.ListFiles

ListFiles creates a pipe containing the files and directories matching the supplied path, one per line. The path may be a glob, conforming to filepath.Match syntax.

View Source
var Slice = script.Slice

Slice creates a pipe containing each element of the supplied slice of strings, one per line.

Functions

func ExecStdout

func ExecStdout(cmds ...string) error

ExecStdout runs an external command and writes the contents of the pipe to the program's standard output.

Types

type Pipe

type Pipe = script.Pipe

Pipe represents a pipe object with an associated ReadAutoCloser. https://pkg.go.dev/github.com/bitfield/script#readme-quick-start-unix-equivalents

func Buffer added in v0.1.1

func Buffer(buf io.Reader) *Pipe

Buffer returns a *Pipe associated with the reader buffers. This is useful for starting pipelines. If there is an error opening the file, the pipe's error status will be set.

func Exec

func Exec(cmds ...string) *Pipe

Exec runs an external command and returns a pipe containing the output.

func ReadFile added in v0.7.1

func ReadFile(name string) *Pipe

ReadFile returns a *Pipe associated with the read all file buffers. This is useful for starting pipelines. If there is an error opening the file, the pipe's error status will be set.

Jump to

Keyboard shortcuts

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