cmdrunner

package
v0.0.0-...-7d3e243 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Timeout specifies timeout for the command to complete. Command will be stooped when timeout reached.
	Timeout time.Duration
	// Tick specifies time interval which is used for command logs output - on each tick
	Tick time.Duration
	// Buffered refers to github.com/go-cmd/cmd.Options.Buffered
	Buffered bool
	// Streaming refers to github.com/go-cmd/cmd.Options.Streaming
	Streaming bool
	// StdoutWriter specifies where to write stdout
	StdoutWriter io.Writer
	// StderrWriter specifies where to write stderr
	StderrWriter io.Writer
}

Options specifies command options

func (*Options) GetOptions

func (opts *Options) GetOptions() gocmd.Options

GetOptions cast options to github.com/go-cmd/cmd.Options

func (*Options) GetStderrWriter

func (opts *Options) GetStderrWriter() io.Writer

GetStderrWriter is a getter

func (*Options) GetStdoutWriter

func (opts *Options) GetStdoutWriter() io.Writer

GetStdoutWriter is a getter

func (*Options) GetTick

func (opts *Options) GetTick() time.Duration

GetTick gets tick from options

func (*Options) GetTimeout

func (opts *Options) GetTimeout() time.Duration

GetTimeout gets timeout from options

func (*Options) HasTick

func (opts *Options) HasTick() bool

HasTick checks whether tick is specified

func (*Options) HasTimeout

func (opts *Options) HasTimeout() bool

HasTimeout checks whether timeout is specified

type Runner

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

Runner specifies command runner

func New

func New(args ...string) *Runner

New creates new runner having all executable command specified as args

func NewWithName

func NewWithName(name string, args ...string) *Runner

NewWithName creates new runner having name and args explicitly separated as in github.com/go-cmd/cmd

func (*Runner) GetExitCode

func (r *Runner) GetExitCode() int

GetExitCode gets exit code. The process should be completed

func (*Runner) GetStatus

func (r *Runner) GetStatus() gocmd.Status

GetStatus is a getter

func (*Runner) GetStatusString

func (r *Runner) GetStatusString() string

GetStatusString gets Status as a meaningful string

func (*Runner) GetStderrLine

func (r *Runner) GetStderrLine(sep string) string

GetStderrLine gets STDERR as a single line concatenated with separator

func (*Runner) GetStderrLines

func (r *Runner) GetStderrLines() []string

GetStderrLines gets STDERR as a slice of lines

func (*Runner) GetStderrReader

func (r *Runner) GetStderrReader() io.Reader

GetStderrReader gets STDERR as a io.Reader

func (*Runner) GetStdoutLine

func (r *Runner) GetStdoutLine(sep string) string

GetStdoutLine gets STDOUT as a single line concatenated with separator

func (*Runner) GetStdoutLines

func (r *Runner) GetStdoutLines() []string

GetStdoutLines gets STDOUT as a slice of lines

func (*Runner) GetStdoutReader

func (r *Runner) GetStdoutReader() io.Reader

GetStdoutReader gets STDOUT as a io.Reader

func (*Runner) Run

func (r *Runner) Run(options *Options) gocmd.Status

Run runs command with options

func (*Runner) SetEnv

func (r *Runner) SetEnv(env []string) *Runner

SetEnv is a setter

func (*Runner) SetWorkdir

func (r *Runner) SetWorkdir(workdir string) *Runner

SetWorkdir is a setter

func (*Runner) WriteOutput

func (r *Runner) WriteOutput(stdout, stderr io.Writer)

WriteOutput writes output into provided stdout and stderr writers from run app's stdout and stderr

Jump to

Keyboard shortcuts

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