cmd

package
v0.0.0-...-0394936 Latest Latest
Warning

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

Go to latest
Published: Jan 23, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command struct {
	Name string
	Args []string
	// contains filtered or unexported fields
}

func NewCommand

func NewCommand(name string, args ...string) *Command

func (*Command) ExitCode

func (c *Command) ExitCode() int

func (*Command) Run

func (c *Command) Run(opts *RunOptions) error

func (*Command) RunStdBytes

func (c *Command) RunStdBytes(opts *RunOptions) (stdout, stderr []byte, err error)

RunStdBytes runs the command with options and returns stdout/stderr as bytes

func (*Command) RunStdString

func (c *Command) RunStdString(opts *RunOptions) (stdout, stderr string, err error)

RunStdString runs the command with options and returns stdout/stderr as string

type RunOptions

type RunOptions struct {
	Dir string
	Env map[string]string

	Stdin io.Reader
	// When using Stdout, it's impossible to use PipeReader
	Stdout io.Writer
	// When using Stderr, it's impossible to use PipeReader
	Stderr io.Writer
	// When using PipeReader, it's impossible to use Stdout or/and Stderr
	PipeReader func(stdout, stderr io.ReadCloser)

	Timeout time.Duration
}

Jump to

Keyboard shortcuts

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