Documentation
¶
Index ¶
- Variables
- func PrettyPath(path string) string
- type Cmd
- type Option
- func CaptureCombined() Option
- func CaptureError() Option
- func CaptureOutput() Option
- func FeedStdin(in io.Reader) Option
- func PassOutput() Option
- func PassStderr() Option
- func PassStdin() Option
- func PassStdio() Option
- func PassStdout() Option
- func WithCombinedError() Option
- func WithCwd(path string) Option
- func WithEnv(key, value string) Option
- func WithSudo(purpose string) Option
- func WithSudoUser(user, purpose string) Option
- func WithUmask(umask os.FileMode) Option
- type Result
Constants ¶
This section is empty.
Variables ¶
var HomeDir = sync.OnceValue(func() string { return internal.Must(os.UserHomeDir()) })
Functions ¶
func PrettyPath ¶
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
func (*Cmd) Run ¶
Run runs the command and waits for it to finish.
If the command fails to start, it returns a nil Result and the error. If the command starts but exits with an error code, the error will be in the Result. This behavior can be overridden with an option to copy the Result error to the top level error, if the caller doesn't care about the distinction.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
func CaptureCombined ¶
func CaptureCombined() Option
func CaptureError ¶ added in v0.9.0
func CaptureError() Option
func CaptureOutput ¶
func CaptureOutput() Option
func FeedStdin ¶
FeedStdin sets the command's Stdin to the provided io.Reader.
The caller is responsible for closing the reader if necessary after the command completes.
func PassOutput ¶
func PassOutput() Option
PassOutput sets the command's Stdout and Stderr to os.Stdout and os.Stderr respectively, and clears any prior capture configuration.
func PassStderr ¶
func PassStderr() Option
PassStderr sets the command's Stderr to os.Stderr and clears any prior capture configuration.
func PassStdout ¶
func PassStdout() Option
PassStdout sets the command's Stdout to os.Stdout and clears any prior capture configuration.
func WithCombinedError ¶
func WithCombinedError() Option
WithCombinedError changes the behavior of Run to return all errors in the error return, instead of only returning errors starting the process there, and errors from the process in the Result.
func WithSudoUser ¶
type Result ¶
type Result struct {
// contains filtered or unexported fields
}
func (*Result) Close ¶
Close releases any resources associated with the result of running a command.
If no output capture was enabled, it is safe to skip calling this.