cli

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Settings = struct {
	// Verbose toggles verbose output for commands.
	Verbose bool
}{}

Settings is global cli settings

Functions

func Command

func Command(command string, args ...string) *exec.Cmd

Command creates a new command.

func CommandInteractive

func CommandInteractive(command string, args ...string) *exec.Cmd

CommandInteractive creates a new interactive command.

func DryRun

func DryRun(d bool)

DryRun toggles the state of the command runner. If true, commands are only printed to the console without execution.

func Prompt

func Prompt(question string) bool

Prompt prompts for input with a question. It returns true only if answer is y or Y.

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) Retry added in v0.3.0

func (a *ActiveCommandChain) Retry(stage string, interval time.Duration, count int, f func() 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.

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() *ActiveCommandChain
	// Logger returns the instance logger.
	Logger() *log.Entry
}

CommandChain is a chain of commands. commands are executed in order.

func New

func New(name string) CommandChain

New creates a new runner instance.

Jump to

Keyboard shortcuts

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