Documentation
¶
Overview ¶
Package command provides a simple facade for running shell commands synchronously.
This package offers a straightforward way to execute shell commands with configurable options for stdout, stderr, stdin, working directory, and environment variables. It uses the options pattern for flexible configuration.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Option ¶
type Option func(cmdOpts *commandOptions)
Option is used to configure command execution.
func WithDir ¶
WithDir sets the working directory for the command. If empty, the command runs in the calling process's current directory.
func WithEnv ¶
WithEnv sets the environment variables for the command. Each entry should be in the form "key=value". If nil, the new process uses the current process's environment.
func WithExtraEnv ¶
WithExtraEnv appends additional environment variables to the current process's environment. Each entry should be in the form "key=value".
func WithStderr ¶
WithStderr sets the writer for the command's standard error.
func WithStdout ¶
WithStdout sets the writer for the command's standard output.
func WithTimeout ¶
WithTimeout sets a timeout for the command execution. If the command does not complete within the specified duration, it will be terminated.