Documentation ¶
Overview ¶
Package shelley runs commands with behavior similar to a command line shell.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var DefaultContext = &Context{ Stdin: os.Stdin, Stdout: os.Stdout, Stderr: os.Stderr, DebugLogger: nil, }
DefaultContext is the Context for commands created by the top level Command function.
Functions ¶
func ExitIfError ¶
func ExitIfError(err error)
ExitIfError exits the current process with a non-zero code if err is non-nil.
If err is an ExitError, the process will exit silently with the same code as the command that generated the error. Otherwise, the error will be logged with the log package and the process will exit with code 1.
This enables an extremely limited but easy to use form of error handling, roughly analogous to "set -e" in a shell script, but without the complex rules and exceptions that many "set -e" users (particularly this author) do not actually understand.
Types ¶
type Cmd ¶
type Cmd struct {
// contains filtered or unexported fields
}
Cmd represents a runnable command.
type Context ¶
type Context struct { // Stdin is the default source for stdin. Stdin io.Reader // Stdout is the default destination for stdout. Stdout io.Writer // Stderr is the default destination for stderr. Stderr io.Writer // DebugLogger logs all commands as they are executed, approximating the // behavior of "set -x" in a shell. Debug lines include environment variables // along with the exact arguments that a command was built with, with shell // quoting for all values. Aliases are not expanded. DebugLogger *log.Logger }
Context provides default settings that affect the execution of commands.