cmd

package
v0.0.0-...-fd6794a Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2020 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewWriter

func NewWriter() (*Writer, *Writer)

func WithRedirect

func WithRedirect(c *Command)

Types

type Command

type Command struct {
	Cmd      string
	Args     []string
	Env      []string
	User     string
	Group    string
	Dir      string
	Redirect bool
	Timeout  *time.Duration
	// contains filtered or unexported fields
}

func New

func New(cmd string, args []string, options ...CommandOption) *Command

func (*Command) Kill

func (c *Command) Kill() (*Status, error)

func (*Command) Running

func (c *Command) Running() bool

func (*Command) Start

func (c *Command) Start() (*Status, error)

func (*Command) Status

func (c *Command) Status() *Status

func (*Command) Stderr

func (c *Command) Stderr() *os.File

func (*Command) Stdout

func (c *Command) Stdout() *os.File

func (*Command) Stop

func (c *Command) Stop() (*Status, error)

func (*Command) String

func (c *Command) String() string

func (*Command) Terminated

func (c *Command) Terminated() bool

func (*Command) Wait

func (c *Command) Wait() (*Status, error)

type CommandOption

type CommandOption func(*Command)

func WithDir

func WithDir(dir string) CommandOption

func WithEnv

func WithEnv(env []string) CommandOption

func WithGroup

func WithGroup(group string) CommandOption

func WithTimeout

func WithTimeout(timeout time.Duration) CommandOption

func WithUser

func WithUser(user string) CommandOption

type Message

type Message struct {
	Received time.Time
	Line     int
	Stderr   bool
	Message  string
}

type Reader

type Reader struct {
	BytesRead int
	// contains filtered or unexported fields
}

func (*Reader) Read

func (r *Reader) Read(p []byte) (n int, err error)

type Status

type Status struct {
	Running    bool                `json:"running"`
	Terminated bool                `json:"terminated"`
	Started    *time.Time          `json:"started,omitempty"`
	Finished   *time.Time          `json:"finished,omitempty"`
	Duration   *time.Duration      `json:"duration,omitempty"`
	Error      *string             `json:"error,omitempty"`
	ExitCode   *syscall.WaitStatus `json:"exitCode,omitempty"`
	Signal     *syscall.Signal     `json:"signal,omitempty"`
}

type Writer

type Writer struct {
	// contains filtered or unexported fields
}

func (*Writer) Chan

func (w *Writer) Chan() <-chan Message

func (*Writer) Close

func (w *Writer) Close() error

func (*Writer) Write

func (w *Writer) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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