cmd

package
v1.2.2 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2019 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 {
	Cmd     string
	Env     []string
	Dir     string
	Timeout time.Duration
	// contains filtered or unexported fields
}

Command represents a single command which can be executed

func NewCommand

func NewCommand(cmd string) *Command

NewCommand creates a new command

func (*Command) AddEnv added in v0.3.0

func (c *Command) AddEnv(key string, value string)

AddEnv adds an environment variable to the command If a variable gets passed like ${VAR_NAME} the env variable will be read out by the current shell

func (*Command) Execute

func (c *Command) Execute() error

Execute executes the command and writes the results into it's own instance The results can be received with the Stdout(), Stderr() and ExitCode() methods

func (*Command) Executed

func (c *Command) Executed() bool

Executed returns if the command was already executed

func (*Command) ExitCode

func (c *Command) ExitCode() int

ExitCode returns the exit code of the command

func (*Command) SetTimeout added in v1.0.0

func (c *Command) SetTimeout(timeout string) error

SetTimeout sets the timeout given a time unit Example: SetTimeout("100s") sets the timeout to 100 seconds

func (*Command) SetTimeoutMS

func (c *Command) SetTimeoutMS(ms int)

SetTimeoutMS sets the timeout in milliseconds

func (*Command) Stderr

func (c *Command) Stderr() string

Stderr returns the output to stderr

func (*Command) Stdout

func (c *Command) Stdout() string

Stdout returns the output to stdout

Jump to

Keyboard shortcuts

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