shell

package
v2.8.2 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandExists

func CommandExists(name string) bool

CommandExists returns true if the given command can be found on the shell

func CreateCommand

func CreateCommand(directory string, command string, args ...string) *exec.Cmd

CreateCommand returns a *Cmd struct that when run, will run the given command + args in the given directory

func RemoveEnv added in v2.3.0

func RemoveEnv(env []string, key string) []string

func RunCommand

func RunCommand(directory string, command string, args ...string) (string, string, error)

RunCommand will run the given command + args in the given directory Will return stdout, stderr and error

func RunCommandVerbose

func RunCommandVerbose(directory string, command string, args ...string) error

RunCommandVerbose will run the given command + args in the given directory Will return an error if one occurs

func RunCommandWithEnv added in v2.3.0

func RunCommandWithEnv(env []string, directory string, command string, args ...string) (string, string, error)

RunCommandWithEnv will run the given command + args in the given directory and using the specified env.

Env specifies the environment of the process. Each entry is of the form "key=value". If Env is nil, the new process uses the current process's environment.

Will return stdout, stderr and error

func SetEnv added in v2.3.0

func SetEnv(env []string, key string, value string) []string

func UpsertEnv added in v2.3.0

func UpsertEnv(env []string, key string, update func(v string) string) []string

Types

type Command

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

func NewCommand

func NewCommand(command string) *Command

func (*Command) AddArgs

func (c *Command) AddArgs(args []string)

func (*Command) Dir

func (c *Command) Dir(dir string)

func (*Command) Env

func (c *Command) Env(name string, value string)

func (*Command) Run

func (c *Command) Run() error

func (*Command) Stderr

func (c *Command) Stderr() string

func (*Command) Stdout

func (c *Command) Stdout() string

Jump to

Keyboard shortcuts

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