Documentation
¶
Index ¶
- type Command
- func (c *Command) DidError() bool
- func (c *Command) Error() error
- func (c *Command) InDir(dir string) *Command
- func (c *Command) Run() (string, error)
- func (c *Command) RunWithContext(ctx *context.Context) (string, error)
- func (c *Command) SanitisedArgs() []string
- func (c Command) String() string
- func (c *Command) WithArg(arg string) *Command
- func (c *Command) WithArgs(args ...string) *Command
- func (c *Command) WithEnv(env map[string]string) *Command
- func (c *Command) WithEnvVariable(name string, value string) *Command
- func (c *Command) WithTimeout(timeout time.Duration) *Command
- type Error
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 Dir string In io.Reader Out io.Writer Err io.Writer Env map[string]string Timeout time.Duration // contains filtered or unexported fields }
Command is a struct containing the details of an external command to be executed
func NewWithVarArgs ¶
NewWithVarArgs construct new command based on a string array
func (*Command) DidError ¶
DidError returns a boolean if any error occurred in any execution of the command
func (*Command) InDir ¶
InDir Setter method for Dir to enable use of interface instead of Command struct
func (*Command) Run ¶
Run Execute the command without retrying on failure and block waiting for return values
func (*Command) RunWithContext ¶
RunWithContext private method executes the command and wait for the result
func (*Command) SanitisedArgs ¶
SanitisedArgs sanitises any password arguments before printing the error string. The actual sensitive argument is still present in the Command object
func (*Command) WithArgs ¶
WithArgs Setter method for Args to enable use of interface instead of Command struct
func (*Command) WithEnv ¶
WithEnv Setter method for Env to enable use of interface instead of Command struct
func (*Command) WithEnvVariable ¶
WithEnvVariable sets an environment variable into the environment