exec

package
v0.7.8-1 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2018 License: MPL-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuildExec added in v0.7.8

func BuildExec(cmd Cmd) (*exec.Cmd, bytes.Buffer)

BuildExec translates FOSSA exec structures into standard library exec commands.

func Run

func Run(cmd Cmd) (stdout, stderr string, err error)

Run executes a `Cmd`.

func Shell added in v0.7.0

func Shell(cmd Cmd) (stdout, stderr string, err error)

func Which

func Which(arg string, cmds ...string) (cmd string, output string, err error)

Which picks a command out of a list of candidates.

func WhichArgs

func WhichArgs(argv []string, cmds ...string) (cmd string, output string, err error)

WhichArgs is `Which` but passes multiple arguments to each candidate.

func WhichWithResolver

func WhichWithResolver(cmds []string, resolve WhichResolver) (string, string, error)

WhichWithResolver is `Which` with a custom resolution strategy.

Types

type Cmd

type Cmd struct {
	Name    string   // Executable name.
	Argv    []string // Executable arguments.
	Command string   // Shell command.

	Dir string // The Command's working directory.

	// If neither Env nor WithEnv are set, the environment is inherited from os.Environ().
	Env     map[string]string // If set, the command's environment is _set_ to Env.
	WithEnv map[string]string // If set, the command's environment is _added_ to WithEnv.
}

Cmd represents a single command. If Name and Argv are set, this is treated as an executable. If Command is set, this is treated as a shell command.

type WhichResolver

type WhichResolver func(cmd string) (output string, ok bool, err error)

A WhichResolver takes a candidate command and returns whether to choose it.

Jump to

Keyboard shortcuts

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