Documentation ¶
Index ¶
- Variables
- func Run(registry *Registry, arguments []string) error
- type Builder
- func (b *Builder) Arg(name string, validator ...Validator) *Builder
- func (b *Builder) ContinueOnError() *Builder
- func (b *Builder) Defer(names ...string) *Builder
- func (b *Builder) DependsOn(names ...string) *Builder
- func (b *Builder) Description(description string) *Builder
- func (b *Builder) Do(executor Executor)
- func (b *Builder) Hide() *Builder
- func (b *Builder) OptionalArg(name string) *Builder
- func (b *Builder) OptionalArgs(names ...string) *Builder
- func (b *Builder) RequiredArg(name string) *Builder
- func (b *Builder) RequiredArgs(names ...string) *Builder
- type Context
- type ContextParam
- type DeclaredTaskArg
- type Executor
- type Registry
- type RegistryOption
- type TUI
- type Task
- type Validator
Constants ¶
This section is empty.
Variables ¶
var Required = Validator(func(name, s string) error { if s == "" { return fmt.Errorf("argument %q is required, but was not supplied", name) } return nil })
Required is a validator that ensures that an argument is present.
Functions ¶
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent way to build up a task.
func (*Builder) ContinueOnError ¶
ContinueOnError declares that a task should not stop the build from continuing.
func (*Builder) Description ¶
Description sets the description for the task.
func (*Builder) OptionalArg ¶
OptionalArg declares an optional argument for the task.
func (*Builder) OptionalArgs ¶
OptionalArgs declares optional arguments for the task.
func (*Builder) RequiredArg ¶
RequiredArg declares a required argument for the task.
func (*Builder) RequiredArgs ¶
RequiredArgs declares required arguments for the task.
type Context ¶
type Context struct { context.Context UI *TUI Verbose bool // contains filtered or unexported fields }
Context holds information relevant to executing tasks.
func NewContext ¶
func NewContext(ctx context.Context, w io.Writer, taskArgs map[string]string, params ...ContextParam) *Context
NewContext makes a new Context.
func (*Context) Get ¶
Get returns an argument of the given name. If one doesn't exist, a lookup in the environment will be made.
func (*Context) Log ¶
func (ctx *Context) Log(v ...interface{})
Log formats using the default formats for its operands sends it to the log. Spaces are added between operands when neither is a string.
type ContextParam ¶
type ContextParam = func(ctx *Context)
func WithUI ¶
func WithUI(ui *TUI) ContextParam
func WithVerbose ¶
func WithVerbose(verbose bool) ContextParam
type DeclaredTaskArg ¶
DeclaredTaskArg is an argument for a particular task.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds all the tasks able to be run.
func NewRegistry ¶
func NewRegistry(opts ...RegistryOption) *Registry
NewRegistry creates a new registry.
type RegistryOption ¶
type RegistryOption func(r *Registry)
RegistryOption is an option for setting up a task registry.
func WithAutoNamespaces ¶
func WithAutoNamespaces(v bool) RegistryOption
WithAutoNamespaces tells the registry whether to automatically create namespace tasks.
func WithNamespaceSeparator ¶
func WithNamespaceSeparator(s string) RegistryOption
WithNamespaceSeparator sets the separator for namespaces.
func WithShouldErrorOnUnusedArgs ¶
func WithShouldErrorOnUnusedArgs(v bool) RegistryOption
WithShouldErrorOnUnusedArgs sets whether we should return an error when unused args are detected.
type TUI ¶
type TUI struct{}
TUI is responsible for setting coloring information.