command

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package command provides helpers to execute external commands with logging.

Index

Constants

This section is empty.

Variables

View Source
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

func GetExecutablePath(commandOverrides map[string]string, commandName string) string

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

func Output(ctx context.Context, command string, arg ...string) (string, error)

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

func Run(ctx context.Context, command string, arg ...string) error

Run executes a program (with arguments). On error, stderr is included in the error message. It is a convenience wrapper around RunWithEnv.

func RunInDir added in v0.8.1

func RunInDir(ctx context.Context, dir, command string, arg ...string) error

RunInDir executes a program in a specific directory.

func RunWithEnv added in v0.8.0

func RunWithEnv(ctx context.Context, env map[string]string, command string, arg ...string) error

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.

Jump to

Keyboard shortcuts

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