invoke

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 6, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Overview

Package invoke provides support for invoking a command. It wraps the standard os/exec package, returning a custom error type that will additionally report the command arguments and the entire content of the invoked command stderr.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Output

func Output(cmd *exec.Cmd) ([]byte, error)

Output invokes cmd and returns the stdout content, with whitespace trimmed.

In case the command exits with a non 0 exit status, the error will contain the entire content of the command stderr, with whitespace trimmed.

func Run

func Run(cmd *exec.Cmd) error

Run runs cmd.

In case the command exits with a non 0 exit status, the error will contain the entire content of the command stderr, with whitespace trimmed.

Types

type Error

type Error struct {
	Cmd    string   // the command invoked
	Argv   []string // arguments to the command
	Stderr []byte   // the entire content of the command stderr
	Err    error    // the original error from os/exec.Command.Run
}

Error is the error returned when a command returns an error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) Unwrap

func (e *Error) Unwrap() error

Unwrap implements the Wrapper interface.

Jump to

Keyboard shortcuts

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