shell

package
v0.0.14 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CommandInstalled

func CommandInstalled(command string) bool

Return true if the OS has the given command installed

func CommandInstalledE

func CommandInstalledE(command string) error

CommandInstalledE returns an error if command is not installed

func GetExitCodeForRunCommandError

func GetExitCodeForRunCommandError(err error) (int, error)

GetExitCodeForRunCommandError tries to read the exit code for the error object returned from running a shell command. This is a bit tricky to do in a way that works across platforms.

func KeysStringString

func KeysStringString(m map[string]string) string

func RunCommand

func RunCommand(command Command) error

RunCommand runs a shell command and redirects its stdout and stderr to the stdout of the atomic script itself.

func RunCommandAndGetOutput

func RunCommandAndGetOutput(command Command) (string, error)

RunCommandAndGetOutput runs a shell command and returns its stdout and stderr as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier.

func RunCommandAndGetStdOut

func RunCommandAndGetStdOut(command Command) (string, error)

RunCommandAndGetStdOut runs a shell command and returns solely its stdout (but not stderr) as a string. The stdout and stderr of that command will also be printed to the stdout and stderr of this Go program to make debugging easier.

func RunShellCommand

func RunShellCommand(command Command) error

Run the specified shell command with the specified arguments. Connect the command's stdin, stdout, and stderr to the currently running app.

func RunShellCommandAndGetAndStreamOutput

func RunShellCommandAndGetAndStreamOutput(command Command) (string, error)

Run the specified shell command with the specified arguments. Return its stdout and stderr as a string and also stream stdout and stderr to the OS stdout/stderr

func RunShellCommandAndGetOutput

func RunShellCommandAndGetOutput(command Command) (string, error)

Run the specified shell command with the specified arguments. Return its stdout and stderr as a string

Types

type Command

type Command struct {
	Command           string            // The command to run
	Args              []string          // The args to pass to the command
	WorkingDir        string            // The working directory
	Env               map[string]string // Additional environment variables to set
	OutputMaxLineSize int               // The max line size of stdout and stderr (in bytes)
	Logger            *logrus.Entry
	NonInteractive    bool
	SensitiveArgs     bool // If true, will not log the arguments to the command
}

Command is a simpler struct for defining commands than Go's built-in Cmd.

Jump to

Keyboard shortcuts

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