task

package module
v3.42.0 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2025 License: MIT Imports: 41 Imported by: 11

README

Task

Task is a task runner / build tool that aims to be simpler and easier to use than, for example, GNU Make.

Installation | Documentation | Twitter | Bluesky | Mastodon | Discord

Gold Sponsors

Documentation

Index

Constants

View Source
const DefaultTaskfile = `` /* 145-byte string literal not displayed */
View Source
const (
	// MaximumTaskCall is the max number of times a task can be called.
	// This exists to prevent infinite loops on cyclic dependencies
	MaximumTaskCall = 1000
)

Variables

View Source
var ErrPreconditionFailed = errors.New("task: precondition not met")

ErrPreconditionFailed is returned when a precondition fails

Functions

func Completion added in v3.39.0

func Completion(completion string) (string, error)

func FilterOutInternal added in v3.18.0

func FilterOutInternal(task *ast.Task) bool

FilterOutInternal removes all tasks that are marked as internal.

func FilterOutNoDesc added in v3.18.0

func FilterOutNoDesc(task *ast.Task) bool

FilterOutNoDesc removes all tasks that do not contain a description.

func InitTaskfile

func InitTaskfile(path string) (string, error)

InitTaskfile creates a new Taskfile at path.

path can be either a file path or a directory path. If path is a directory, path/Taskfile.yml will be created.

The final file path is always returned and may be different from the input path.

func ShouldIgnoreFile added in v3.36.0

func ShouldIgnoreFile(path string) bool

Types

type Call added in v3.42.0

type Call struct {
	Task     string
	Vars     *ast.Vars
	Silent   bool
	Indirect bool // True if the task was called by another task
}

Call is the parameters to a task call

type Compiler added in v3.42.0

type Compiler struct {
	Dir            string
	Entrypoint     string
	UserWorkingDir string

	TaskfileEnv  *ast.Vars
	TaskfileVars *ast.Vars

	Logger *logger.Logger
	// contains filtered or unexported fields
}

func (*Compiler) FastGetVariables added in v3.42.0

func (c *Compiler) FastGetVariables(t *ast.Task, call *Call) (*ast.Vars, error)

func (*Compiler) GetTaskfileVariables added in v3.42.0

func (c *Compiler) GetTaskfileVariables() (*ast.Vars, error)

func (*Compiler) GetVariables added in v3.42.0

func (c *Compiler) GetVariables(t *ast.Task, call *Call) (*ast.Vars, error)

func (*Compiler) HandleDynamicVar added in v3.42.0

func (c *Compiler) HandleDynamicVar(v ast.Var, dir string, e []string) (string, error)

func (*Compiler) ResetCache added in v3.42.0

func (c *Compiler) ResetCache()

ResetCache clear the dynamic variables cache

type Executor

type Executor struct {
	Taskfile *ast.Taskfile

	Dir         string
	Entrypoint  string
	TempDir     TempDir
	Force       bool
	ForceAll    bool
	Insecure    bool
	Download    bool
	Offline     bool
	Timeout     time.Duration
	Watch       bool
	Verbose     bool
	Silent      bool
	AssumeYes   bool
	AssumeTerm  bool // Used for testing
	Dry         bool
	Summary     bool
	Parallel    bool
	Color       bool
	Concurrency int
	Interval    time.Duration

	Stdin  io.Reader
	Stdout io.Writer
	Stderr io.Writer

	Logger             *logger.Logger
	Compiler           *Compiler
	Output             output.Output
	OutputStyle        ast.Output
	TaskSorter         sort.Sorter
	UserWorkingDir     string
	EnableVersionCheck bool
	// contains filtered or unexported fields
}

Executor executes a Taskfile

func (*Executor) CompiledTask

func (e *Executor) CompiledTask(call *Call) (*ast.Task, error)

CompiledTask returns a copy of a task, but replacing variables in almost all properties using the Go template package.

func (*Executor) FastCompiledTask added in v3.2.2

func (e *Executor) FastCompiledTask(call *Call) (*ast.Task, error)

FastCompiledTask is like CompiledTask, but it skippes dynamic variables.

func (*Executor) FindMatchingTasks added in v3.42.0

func (e *Executor) FindMatchingTasks(call *Call) []*MatchingTask

FindMatchingTasks returns a list of tasks that match the given call. A task matches a call if its name is equal to the call's task name or if it matches a wildcard pattern. The function returns a list of MatchingTask structs, each containing a task and a list of wildcards that were matched.

func (*Executor) GetHash added in v3.7.0

func (e *Executor) GetHash(t *ast.Task) (string, error)

func (*Executor) GetTask added in v3.17.0

func (e *Executor) GetTask(call *Call) (*ast.Task, error)

GetTask will return the task with the name matching the given call from the taskfile. If no task is found, it will search for tasks with a matching alias. If multiple tasks contain the same alias or no matches are found an error is returned.

func (*Executor) GetTaskList added in v3.18.0

func (e *Executor) GetTaskList(filters ...FilterFunc) ([]*ast.Task, error)

func (*Executor) InterceptInterruptSignals added in v3.13.0

func (e *Executor) InterceptInterruptSignals()

NOTE(@andreynering): This function intercepts SIGINT and SIGTERM signals so the Task process is not killed immediately and processes running have time to do cleanup work.

func (*Executor) ListTaskNames added in v3.12.0

func (e *Executor) ListTaskNames(allTasks bool) error

ListTaskNames prints only the task names in a Taskfile. Only tasks with a non-empty description are printed if allTasks is false. Otherwise, all task names are printed.

func (*Executor) ListTasks added in v3.18.0

func (e *Executor) ListTasks(o ListOptions) (bool, error)

ListTasks prints a list of tasks. Tasks that match the given filters will be excluded from the list. The function returns a boolean indicating whether tasks were found and an error if one was encountered while preparing the output.

func (*Executor) Run

func (e *Executor) Run(ctx context.Context, calls ...*Call) error

Run runs Task

func (*Executor) RunTask

func (e *Executor) RunTask(ctx context.Context, call *Call) error

RunTask runs a task by its name

func (*Executor) Setup

func (e *Executor) Setup() error

func (*Executor) Status

func (e *Executor) Status(ctx context.Context, calls ...*Call) error

Status returns an error if any the of given tasks is not up-to-date

func (*Executor) ToEditorOutput added in v3.19.1

func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool) (*editors.Taskfile, error)

type FilterFunc added in v3.18.0

type FilterFunc func(task *ast.Task) bool

type ListOptions added in v3.19.1

type ListOptions struct {
	ListOnlyTasksWithDescriptions bool
	ListAllTasks                  bool
	FormatTaskListAsJSON          bool
	NoStatus                      bool
}

ListOptions collects list-related options

func NewListOptions added in v3.19.1

func NewListOptions(list, listAll, listAsJson, noStatus bool) ListOptions

NewListOptions creates a new ListOptions instance

func (ListOptions) Filters added in v3.19.1

func (o ListOptions) Filters() []FilterFunc

Filters returns the slice of FilterFunc which filters a list of ast.Task according to the given ListOptions

func (ListOptions) ShouldListTasks added in v3.19.1

func (o ListOptions) ShouldListTasks() bool

ShouldListTasks returns true if one of the options to list tasks has been set to true

func (ListOptions) Validate added in v3.19.1

func (o ListOptions) Validate() error

Validate validates that the collection of list-related options are in a valid configuration

type MatchingTask added in v3.42.0

type MatchingTask struct {
	Task      *ast.Task
	Wildcards []string
}

MatchingTask represents a task that matches a given call. It includes the task itself and a list of wildcards that were matched.

type TempDir added in v3.38.0

type TempDir struct {
	Remote      string
	Fingerprint string
}

Directories

Path Synopsis
cmd
release command
sleepit command
task command
internal
env
exp
This package is intended as a place to copy functions from the golang.org/x/exp package.
This package is intended as a place to copy functions from the golang.org/x/exp package.
ast

Jump to

Keyboard shortcuts

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