shell

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2019 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var BRIGHT_GREEN = color.New(color.FgHiGreen, color.Bold)
View Source
var NonInteractivePasswordPrompt = fmt.Errorf("The non-interactive flag is set, so unable to prompt user for a password.")

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 FPromptUserForInput

func FPromptUserForInput(out io.Writer, in io.Reader, prompt string, options *ShellOptions) (string, error)

func FPromptUserForYesNo

func FPromptUserForYesNo(out io.Writer, in io.Reader, prompt string, options *ShellOptions) (bool, error)

func PromptUserForInput

func PromptUserForInput(prompt string, options *ShellOptions) (string, error)

Prompt the user for text in the CLI. Returns the text entered by the user.

func PromptUserForPassword

func PromptUserForPassword(prompt string, options *ShellOptions) (string, error)

Prompt a user for a password or other sensitive info that should not be echoed back to stdout.

func PromptUserForYesNo

func PromptUserForYesNo(prompt string, options *ShellOptions) (bool, error)

Prompt the user for a yes/no response and return true if they entered yes.

func RunShellCommand

func RunShellCommand(options *ShellOptions, command string, args ...string) 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(options *ShellOptions, command string, args ...string) (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(options *ShellOptions, command string, args ...string) (string, error)

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

Types

type ShellOptions

type ShellOptions struct {
	NonInteractive bool
	Logger         *logrus.Logger
	WorkingDir     string
	SensitiveArgs  bool              // If true, will not log the arguments to the command
	Env            map[string]string // Additional environment variables to set
}

func NewShellOptions

func NewShellOptions() *ShellOptions

Jump to

Keyboard shortcuts

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