Documentation ¶
Index ¶
- func ExecCmd(ctx context.Context, r **exec.Cmd, cwd string, env map[string]string, ...) (ran bool, err error)
- func ExitStatus(err error) int
- func GetEnvOr(envVar, defaultValue string) string
- func MatchOneOf(text string, patterns ...string) bool
- func NewProgress(prefix string, count int) *pb.ProgressBar
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 ¶
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 MatchOneOf ¶
func NewProgress ¶
Types ¶
This section is empty.