exec

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 7 Imported by: 8

Documentation

Overview

exec is extension of the standard os.exec package. Adds a handy dandy interface and assorted other features.

Index

Constants

This section is empty.

Variables

View Source
var (
	// for equivalence with os/exec
	ErrNotFound = exec.ErrNotFound
	LookPath    = exec.LookPath
)

Functions

func IsCmdNotFound added in v0.2.0

func IsCmdNotFound(err error) bool

IsCmdNotFound reports true if the underlying error was exec.ErrNotFound.

func MaybeExec

func MaybeExec()

MaybeExec should be called at the start of the program, if the process argv[0] is a name registered with multicall, the related function will be executed. If the functions returns an error, it will be printed to stderr and will exit with an exit status of 1, otherwise it will exit with a 0 exit status.

Types

type Cmd

type Cmd interface {
	// Methods provided by exec.Cmd
	CombinedOutput() ([]byte, error)
	Output() ([]byte, error)
	Run() error
	Start() error
	StderrPipe() (io.ReadCloser, error)
	StdinPipe() (io.WriteCloser, error)
	StdoutPipe() (io.ReadCloser, error)
	Wait() error

	// Simplified wrapper for Process.Kill + Wait
	Kill() error

	// Simplified wrapper for Process.Pid
	Pid() int
}

An exec.Cmd compatible interface.

type Entrypoint

type Entrypoint string

Entrypoint provides the access to a multicall command.

func NewEntrypoint

func NewEntrypoint(name string, fn entrypointFn) Entrypoint

NewEntrypoint adds a new multicall command. name is the command name and fn is the function that will be executed for the specified command. It returns the related Entrypoint. Packages adding new multicall commands should call Add in their init function.

func (Entrypoint) Command

func (e Entrypoint) Command(args ...string) *ExecCmd

Command will prepare the *ExecCmd for the given entrypoint, configured with the provided args.

func (Entrypoint) Sudo

func (e Entrypoint) Sudo(args ...string) *ExecCmd

Sudo will prepare the *ExecCmd for the given entrypoint to be run as root via sudo with the provided args.

type ExecCmd

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

Basic Cmd implementation based on exec.Cmd

func Command

func Command(name string, arg ...string) *ExecCmd

func CommandContext added in v0.3.0

func CommandContext(ctx context.Context, name string, arg ...string) *ExecCmd

func (*ExecCmd) Kill

func (cmd *ExecCmd) Kill() error

func (*ExecCmd) Pid added in v0.13.0

func (cmd *ExecCmd) Pid() int

Jump to

Keyboard shortcuts

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