command

package
v0.2.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Available

func Available(commands ...string) (ok bool)

Available verifies that the specified `commands` are available within the current `$PATH` environment and returns true if so. The function does not check for duplicates nor if the provided slice is empty.

func Execute

func Execute(cmd string, args ...string) error

Execute is a convenience function which creates a new Command, executes it and evaluates its status.

Types

type Command

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

A generic command abstraction

func New

func New(cmd string, args ...string) *Command

New creates a new command from the provided arguments.

func NewWithWorkDir

func NewWithWorkDir(workDir, cmd string, args ...string) *Command

NewWithWorkDir creates a new command from the provided workDir and the command arguments.

func (*Command) Pipe

func (c *Command) Pipe(cmd string, args ...string) *Command

Pipe creates a new command where the previous should be piped to

func (*Command) Run

func (c *Command) Run() (res *Status, err error)

Run starts the command and waits for it to finish. It returns an error if the command execution was not possible at all, otherwise the Status. This method prints the commands output during execution

func (*Command) RunSilent

func (c *Command) RunSilent() (res *Status, err error)

Run starts the command and waits for it to finish. It returns an error if the command execution was not possible at all, otherwise the Status. This method does not print the output of the command during its execution.

func (*Command) RunSilentSuccess

func (c *Command) RunSilentSuccess() (err error)

Run starts the command and waits for it to finish. It returns an error if the command execution was not successful. This method does not print the output of the command during its execution.

func (*Command) RunSuccess

func (c *Command) RunSuccess() (err error)

Run starts the command and waits for it to finish. It returns an error if the command execution was not successful.

func (*Command) String

func (c *Command) String() string

String returns a string representation of the full command

type Status

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

A generic command exit status

func (*Status) Error

func (s *Status) Error() string

Error returns the stderr of the command status

func (*Status) ExitCode

func (s *Status) ExitCode() int

ExitCode returns the exit status of the command status

func (*Status) Output

func (s *Status) Output() string

Output returns stdout of the command status

func (*Status) Success

func (s *Status) Success() bool

Success returns if a Status was successful

Jump to

Keyboard shortcuts

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