taskrunner

package
v0.9.1-beta Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTaskRunner

func NewTaskRunner(opts ...Option) (runner *taskRunner)

Types

type ConditionalExecutorFn

type ConditionalExecutorFn func() bool

type ConditionalTask

type ConditionalTask struct {
	Description   string
	Action        func(ctx context.Context) error
	ShouldExecute func() bool
}

func (*ConditionalTask) Describe

func (t *ConditionalTask) Describe() string

func (*ConditionalTask) Task

func (t *ConditionalTask) Task(ctx context.Context) (err error)

type Describer

type Describer interface {
	Describe() string
}

type NoOpOutput

type NoOpOutput struct{}

func (NoOpOutput) ErrorF

func (n NoOpOutput) ErrorF(_ string, _ ...interface{})

func (NoOpOutput) Next

func (n NoOpOutput) Next()

func (NoOpOutput) PrintTaskProgress

func (n NoOpOutput) PrintTaskProgress(_ string)

func (NoOpOutput) Printf

func (n NoOpOutput) Printf(_ string, _ ...interface{})

type Option

type Option func(tr *taskRunner) *taskRunner

func WithDiscardOutput

func WithDiscardOutput() Option

func WithPTermOutput

func WithPTermOutput(output *ptermTaskRunnerOutput) Option

func WithTasks

func WithTasks(tasks ...Tasker) Option

func WithTimeout

func WithTimeout(timeout time.Duration) Option

func WithTitle

func WithTitle(title string) Option

type Runner

type Runner interface {
	Describer
	Run(ctx context.Context) error
	Wrap(executeWhenTrue ConditionalExecutorFn) Tasker
}

type SimpleTask

type SimpleTask struct {
	Description string
	Action      func(ctx context.Context) error
}

func (*SimpleTask) Describe

func (t *SimpleTask) Describe() string

func (*SimpleTask) Task

func (t *SimpleTask) Task(ctx context.Context) (err error)

type Task

type Task struct {
	Description string
	Root        string
	Plugin      plugins2.Executor
	Args        []string
}

func (*Task) Describe

func (t *Task) Describe() string

func (*Task) Task

func (t *Task) Task(ctx context.Context) (err error)

type TaskActionFn

type TaskActionFn func(ctx context.Context) error

type TaskRunnerMsg

type TaskRunnerMsg interface {
	Print(output TaskRunnerOutput)
	Error() error
}

type TaskRunnerOutput

type TaskRunnerOutput interface {
	ErrorF(format string, args ...interface{})
	Printf(format string, args ...interface{})
	PrintTaskProgress(string string)
	Next()
}

type Tasker

type Tasker interface {
	Describer
	Task(ctx context.Context) (err error)
}

func NewConditionalTask

func NewConditionalTask(desc string, task TaskActionFn, shouldExecuteFn ConditionalExecutorFn) Tasker

type Tasks

type Tasks []Tasker

func (Tasks) Filter

func (t Tasks) Filter(filterFn func(tasker Tasker) bool) (result Tasks)

func (Tasks) MapToString

func (t Tasks) MapToString(mapFn func(tasker Tasker) string) (result []string)

Jump to

Keyboard shortcuts

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