Documentation
¶
Overview ¶
Package command provides helpers to execute external commands with logging.
Index ¶
- Variables
- func GetExecutablePath(commandOverrides map[string]string, commandName string) string
- func Output(ctx context.Context, command string, arg ...string) (string, error)
- func OutputWithEnv(ctx context.Context, env map[string]string, command string, arg ...string) (string, error)
- func Run(ctx context.Context, command string, arg ...string) error
- func RunInDir(ctx context.Context, dir, command string, arg ...string) error
- func RunWithEnv(ctx context.Context, env map[string]string, command string, arg ...string) error
Constants ¶
This section is empty.
Variables ¶
var Verbose bool
Verbose controls whether commands are printed to stderr before execution.
TODO(https://github.com/googleapis/librarian/issues/3687): pass in as config.
Functions ¶
func GetExecutablePath ¶ added in v0.8.0
GetExecutablePath finds the path for a given command, checking for an override in the provided commandOverrides map first.
func Output ¶ added in v0.8.1
Output executes a program (with arguments) and returns stdout. It is a convenience wrapper around OutputWithEnv.
func OutputWithEnv ¶ added in v0.8.1
func OutputWithEnv(ctx context.Context, env map[string]string, command string, arg ...string) (string, error)
OutputWithEnv executes a program (with arguments) and optional environment variables and returns stdout. If env is nil or empty, the command inherits the environment of the calling process. On error, stderr is included in the error message.
func Run ¶
Run executes a program (with arguments). On error, stderr is included in the error message. It is a convenience wrapper around RunWithEnv.
func RunWithEnv ¶ added in v0.8.0
RunWithEnv executes a program (with arguments) and optional environment variables and captures any error output. If env is nil or empty, the command inherits the environment of the calling process.
Types ¶
This section is empty.