task

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package task handles core spok functionality related to the processing of declared tasks e.g. expanding glob patterns, parsing from an ast node etc.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Task           string        `json:"task"`    // The name of the task
	CommandResults shell.Results `json:"results"` // The results of running the tasks commands
	Skipped        bool          `json:"skipped"` // Whether the task was skipped or run
}

Result encodes the overall result of running a task which may involve any number of shell commands.

func (Result) Ok

func (r Result) Ok() bool

Ok returns whether or not the task was successful, true if all commands exited with 0, else false.

type Results

type Results []Result

Results is a collection of task results.

func (Results) JSON

func (r Results) JSON() (string, error)

JSON returns the Results as JSON.

func (Results) Ok

func (r Results) Ok() bool

Ok reports whether all results in the collection are ok.

type Task

type Task struct {
	Doc              string   // The task docstring
	Name             string   // Task name
	TaskDependencies []string // Other tasks or idents this task depends on (by name)
	FileDependencies []string // Filepaths this task depends on
	GlobDependencies []string // Filepath dependencies that are specified as glob patterns
	Commands         []string // Shell commands to run
	NamedOutputs     []string // Other outputs by ident
	FileOutputs      []string // Filepaths this task outputs
	GlobOutputs      []string // Filepaths this task outputs that are specified as glob patterns
}

Task represents a spok Task.

func New

func New(t ast.Task, root string, vars map[string]string) (Task, error)

New parses a task AST node into a concrete task, root is the absolute path of the directory to use as the root for glob expansion, typically the path to the spokfile.

func (*Task) Run

func (t *Task) Run(runner shell.Runner, stream iostream.IOStream, env []string) (shell.Results, error)

Run runs a task commands in order, echoing each one to out and returning the list of results containing the exit status, stdout and stderr of each command.

If the task has no commands, this becomes a no-op.

Jump to

Keyboard shortcuts

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