action

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMissingInput = errors.New("missing input")

Functions

This section is empty.

Types

type Action

type Action interface {
	Combinable
	Runner
	Printer

	fmt.Stringer // Required for checksums.
}

Action defines a type which can be executed, both in live mode and in dry-run mode, as well as combine with other Action implementers.

func InOrder added in v0.1.1

func InOrder(actions ...Action) Action

InOrder creates a wrapper action which executes the specified 'Action' types in order.

type Actioner

type Actioner interface {
	Action() (Action, error)
}

type Combinable

type Combinable interface {
	After(a Action) Action
	AndThen(a Action) Action
}

type Command

type Command string

Command is a string which is interpreted as a shell script.

func (Command) After

func (c Command) After(a Action) Action

After creates a new action which executes the provided action and then the wrapped command.

func (Command) AndThen

func (c Command) AndThen(a Action) Action

AndThen creates a new action which executes the wrapped command and then the provided action.

func (Command) Process added in v0.1.1

func (c Command) Process() *Process

func (Command) Run

func (c Command) Run(ctx context.Context) error

Run executes the underlying shell command as a 'Process'.

func (Command) Sprint

func (c Command) Sprint() string

Sprint displays the action without actually executing it.

func (Command) String added in v0.1.2

func (c Command) String() string

type Commands

type Commands struct {
	Commands []Command
	Shell    exec.Shell
	Verbose  bool
}

Commands is a group of string commands which are executed in order.

func (Commands) After

func (c Commands) After(a Action) Action

After creates a new action which executes the provided action and then the wrapped list of commands.

func (Commands) AndThen

func (c Commands) AndThen(a Action) Action

AndThen creates a new action which executes the wrapped list of commands and then the provided action.

func (Commands) Run

func (c Commands) Run(ctx context.Context) error

Run executes the underlying shell commands in order.

func (Commands) Sprint

func (c Commands) Sprint() string

Sprint displays the action without actually executing it.

func (Commands) String added in v0.1.2

func (c Commands) String() string

type Function

type Function func(context.Context) error

Function is a wrapper for a Go-based action.

func (Function) After

func (f Function) After(a Action) Action

After creates a new action which executes the provided action and then the wrapped function.

func (Function) AndThen

func (f Function) AndThen(a Action) Action

AndThen creates a new action which executes the wrapped function and then the provided action.

func (Function) Run

func (f Function) Run(ctx context.Context) error

Run executes the underlying function.

func (Function) Sprint

func (f Function) Sprint() string

Sprint displays the action without actually executing it.

func (Function) String added in v0.1.2

func (f Function) String() string

type Printer

type Printer interface {
	Sprint() string
}

type Process

type Process exec.Process

Process is a child process.

func (*Process) After

func (p *Process) After(a Action) Action

After creates a new action which executes the provided action and then the wrapped function.

func (*Process) AndThen

func (p *Process) AndThen(a Action) Action

AndThen creates a new action which executes the wrapped function and then the provided action.

func (*Process) Run

func (p *Process) Run(ctx context.Context) error

Run executes the underlying function.

func (*Process) Sprint

func (p *Process) Sprint() string

Sprint displays the action without actually executing it.

func (*Process) String added in v0.1.2

func (p *Process) String() string

type Runner

type Runner interface {
	Run(ctx context.Context) error
}

Runner is a type which can execute an arbitrary action or command.

type Sequence

type Sequence struct {
	Pre    Runner
	Action Runner
	Post   Runner
}

Sequence is an action which is solely comprised of a sequence of other action types.

func (Sequence) After

func (s Sequence) After(r Action) Action

After creates a new action which executes the provided action and then all of the actions in this sequence.

func (Sequence) AndThen

func (s Sequence) AndThen(r Action) Action

AndThen creates a new action which executes all actions in this sequence and then the provided action.

func (Sequence) Run

func (s Sequence) Run(ctx context.Context) error

Run executes all actions in the sequence.

func (Sequence) Sprint

func (s Sequence) Sprint() string

Sprint displays the action without actually executing it.

func (Sequence) String added in v0.1.2

func (s Sequence) String() string

func (Sequence) Unwrap added in v0.0.4

func (s Sequence) Unwrap() Runner

Unwrap recursively unwraps a sequence to get the central 'Runner'.

type WithDescription

type WithDescription[T Action] struct {
	Action      T
	Description string
}

WithDescription is a utility type for wrapping an action with a description that replaces a 'Print' call.

func (WithDescription[T]) After

func (d WithDescription[T]) After(a Action) Action

After creates a new action which executes the provided action and then the wrapped action.

func (WithDescription[T]) AndThen

func (d WithDescription[T]) AndThen(a Action) Action

AndThen creates a new action which executes the wrapped action and then the provided action.

func (WithDescription[T]) Run

func (d WithDescription[T]) Run(ctx context.Context) error

Run executes the underlying action.

func (WithDescription[T]) Sprint

func (d WithDescription[T]) Sprint() string

Sprint displays the action without actually executing it.

func (WithDescription[T]) String added in v0.1.2

func (d WithDescription[T]) String() string

Jump to

Keyboard shortcuts

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