exec

package
v1.10.3 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2021 License: Apache-2.0 Imports: 8 Imported by: 20

Documentation

Overview

Package exec provides useful wrappers around the standard "exec" library.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cmd

type Cmd struct {
	*exec.Cmd
	// contains filtered or unexported fields
}

Cmd wraps exec.Cmd with a context to provide convenient execution of a command with nice checking of the context timeout in the form:

err := exec.Prog().WithTimeout(5*time.Second, myprog, myargs...).CombinedOutput(log, verbose)

func CommandContext

func CommandContext(ctx context.Context, prog string, args ...string) *Cmd

CommandContext wraps exec.CommandContext to allow this package to be used as a drop-in replacement for the standard exec library.

func WithCancel

func WithCancel(ctx context.Context, prog string, args ...string) (*Cmd, context.CancelFunc)

WithCancel creates a Cmd with a context that can be cancelled by calling the resulting Cancel() function.

func WithTimeout

func WithTimeout(timeout time.Duration, prog string, args ...string) *Cmd

WithTimeout creates a Cmd with a context that times out after the specified duration.

func (*Cmd) CombinedOutput

func (c *Cmd) CombinedOutput(scopedLog *logrus.