Documentation ¶
Index ¶
- Variables
- func Command(command string, args ...string) *exec.Cmd
- func CommandInteractive(command string, args ...string) *exec.Cmd
- func ErrNonFatal(err error) error
- func Prompt(question string) bool
- type ActiveCommandChain
- func (a *ActiveCommandChain) Add(f func() error)
- func (a *ActiveCommandChain) Exec() error
- func (a *ActiveCommandChain) Logger() *log.Entry
- func (a *ActiveCommandChain) Retry(stage string, interval time.Duration, count int, f func(retryCount int) error)
- func (a *ActiveCommandChain) Stage(s string)
- func (a *ActiveCommandChain) Stagef(format string, s ...interface{})
- type CommandChain
Constants ¶
This section is empty.
Variables ¶
var CtxKeyQuiet = struct{ key string }{/* contains filtered or unexported fields */}
CtxKeyQuiet is the context key to mute the chain.
var Settings = struct { // Verbose toggles verbose output for commands. Verbose bool }{}
Settings is global cli settings
Functions ¶
func CommandInteractive ¶
CommandInteractive creates a new interactive command.
func ErrNonFatal ¶ added in v0.5.3
ErrNonFatal creates a non-fatal error for a command chain. A warning would be printed instead of terminating the chain.
Types ¶
type ActiveCommandChain ¶
type ActiveCommandChain struct {
// contains filtered or unexported fields
}
ActiveCommandChain is an active command chain.
func (*ActiveCommandChain) Add ¶
func (a *ActiveCommandChain) Add(f func() error)
Add adds a new function to the runner.
func (*ActiveCommandChain) Exec ¶
func (a *ActiveCommandChain) Exec() error
Exec executes the command chain. The first errored function terminates the chain and the error is returned. Otherwise, returns nil.
func (*ActiveCommandChain) Logger ¶ added in v0.6.0
func (a *ActiveCommandChain) Logger() *log.Entry
Logger returns the logger for the command chain.
func (*ActiveCommandChain) Retry ¶ added in v0.3.0
func (a *ActiveCommandChain) Retry(stage string, interval time.Duration, count int, f func(retryCount int) error)
Retry retries `f` up to `count` times at interval. If after `count` attempts there is an error, the command chain is terminated with the final error. retryCount starts from 1.
func (*ActiveCommandChain) Stage ¶
func (a *ActiveCommandChain) Stage(s string)
Stage sets the current stage of the runner.
func (*ActiveCommandChain) Stagef ¶
func (a *ActiveCommandChain) Stagef(format string, s ...interface{})
Stagef is like stage with string format.
type CommandChain ¶
type CommandChain interface { // Init initiates a new runner using the current instance. Init(ctx context.Context) *ActiveCommandChain // Logger returns the instance logger. Logger(ctx context.Context) *log.Entry }
CommandChain is a chain of commands. commands are executed in order.