utils

package
v0.0.0-...-a595894 Latest Latest
Warning

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

Go to latest
Published: Jul 10, 2019 License: NCSA Imports: 10 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExecCmd

func ExecCmd(ctx context.Context, r **exec.Cmd, cwd string, env map[string]string, stdout, stderr io.Writer, cmd string, args ...string) (ran bool, err error)

Exec executes the command, piping its stderr to mage's stderr and piping its stdout to the given writer. If the command fails, it will return an error that, if returned from a target or mg.Deps call, will cause mage to exit with the same code as the command failed with. Env is a list of environment variables to set when running the command, these override the current environment variables set (which are also passed to the command). cmd and args may include references to environment variables in $FOO format, in which case these will be expanded before the command is run.

Ran reports if the command ran (rather than was not found or not executable). Code reports the exit code the command returned if it ran. If err == nil, ran is always true and code is always 0.

func ExitStatus

func ExitStatus(err error) int

ExitStatus returns the exit status of the error if it is an exec.ExitError or if it implements ExitStatus() int. 0 if it is nil or 1 if it is a different error.

func GetEnvOr

func GetEnvOr(envVar, defaultValue string) string

func MatchOneOf

func MatchOneOf(text string, patterns ...string) bool

func NewProgress

func NewProgress(prefix string, count int) *pb.ProgressBar

Types

This section is empty.

Jump to

Keyboard shortcuts

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