Documentation ¶
Overview ¶
Package harness provides a set of primitives that can be used to build a magefile without having to set everything from the ground up.
Index ¶
- func Run(ctx context.Context, program string, opts ...RunnerOpt) error
- type Harness
- type Option
- type RunnerOpt
- func WithAllowErrors() RunnerOpt
- func WithArgs(args ...string) RunnerOpt
- func WithDir(dir string) RunnerOpt
- func WithEnv(vars ...string) RunnerOpt
- func WithErrMsg(msg string) RunnerOpt
- func WithOKMsg(msg string) RunnerOpt
- func WithStdIn(read io.Reader) RunnerOpt
- func WithStdOut(w io.Writer) RunnerOpt
- func WithoutNoise() RunnerOpt
- type Task
- type TaskRunner
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Harness ¶
Harness is a support structure that runs tasks, the harness can be customized with pre- and post- execution hook functions, where common functionality to all tasks can be defined.
type Option ¶
type Option func(h *Harness)
func WithPreExecFunc ¶
WithPreExecFunc allows specifying a task that will be run every execution, before the specific execution tasks are run.
type RunnerOpt ¶
type RunnerOpt func(r *TaskRunner) error
RunnerOpt allows customizing the behavior of the command runner.
func WithAllowErrors ¶
func WithAllowErrors() RunnerOpt
WithAllowErrors allow errors in the command.
func WithErrMsg ¶
WithErrMsg sets a message to be printed when the command fails.
func WithoutNoise ¶
func WithoutNoise() RunnerOpt
WithoutNoise silences all output for the command; useful when handling that on the caller side.
type Task ¶
Task defines the basic function that the harness executes. Additional configuration and tweaks can be done by using clojures which return Tasks.
type TaskRunner ¶
type TaskRunner struct { Executable string Arguments []string // contains filtered or unexported fields }
TaskRunner holds the metadata for a specific command.
func (*TaskRunner) Exec ¶
func (r *TaskRunner) Exec() error
Exec a command returning its error and pretty printing the ok and error messages.