shell

package
v0.0.0-...-4cb4cf9 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const ShellProgram = "/bin/bash"

ShellProgram is the default shell program used by the tooling.

Variables

This section is empty.

Functions

func CurrentEnvironment

func CurrentEnvironment() []string

CurrentEnvironment returns the current environment variables that are being used for all processes launched from this package.

func Execute

func Execute(program string, args ...string) (stdout, stderr string, err error)

Execute runs the provided command.

func ExecuteAndLogToFile

func ExecuteAndLogToFile(filepath string, command string, args ...string)

ExecuteAndLogToFile runs a command in the shell and redirects stdout to the given file

func ExecuteInDirectory

func ExecuteInDirectory(workingDirectory, program string, args ...string) (stdout, stderr string, err error)

Execute runs the provided command in a specific working directory.

func ExecuteLive

func ExecuteLive(squashErrors bool, program string, args ...string) (err error)

ExecuteLive runs a command in the shell and logs it in real-time

func ExecuteLiveWithCallback

func ExecuteLiveWithCallback(onStdout, onStderr func(...interface{}), printOutputOnError bool, program string, args ...string) (err error)

ExecuteLiveWithCallback runs a command in the shell and invokes the provided callbacks in real-time on each line of stdout and stderr. If printOutputOnError is true, the full output of the command will be printed after completion if the command returns an error. In the event the buffer becomes full the oldest buffered output is discarded.

func ExecuteLiveWithCallbackAndChannels

func ExecuteLiveWithCallbackAndChannels(onStdout, onStderr func(...interface{}),
	stdoutChannel, stderrChannel chan string,
	program string, args ...string,
) (err error)

func ExecuteLiveWithErr

func ExecuteLiveWithErr(stderrLines int, program string, args ...string) (err error)

ExecuteLiveWithErr runs a command in the shell and logs it in real-time. In addition, if there is an error, the last x lines of stderr will be attached to the err object.

func ExecuteLiveWithErrAndCallbacks

func ExecuteLiveWithErrAndCallbacks(stderrLines int, onStdout, onStderr func(...interface{}), program string,
	args ...string,
) (err error)

ExecuteLiveWithErr runs a command in the shell and logs it in real-time. In addition, if there is an error, the last x lines of stderr will be attached to the err object.

func ExecuteWithStdin

func ExecuteWithStdin(input, program string, args ...string) (stdout, stderr string, err error)

ExecuteWithStdin - Run the command and use Stdin to pass input during execution

func MustExecuteLive

func MustExecuteLive(command string, args ...string)

MustExecuteLive executes the shell command. Panics on failure.

func PermanentlyStopAllChildProcesses

func PermanentlyStopAllChildProcesses(signal unix.Signal)

PermanentlyStopAllChildProcesses will send the provided signal to all processes spawned by this package, and all of those process's children. Invoking this will also block future process creation, causing the Execute methods to return an error.

func SetEnvironment

func SetEnvironment(env []string)

SetEnvironment sets the default environment variables to be used for all processes launched from this package.

Types

This section is empty.

Jump to

Keyboard shortcuts

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