Documentation
¶
Index ¶
- Constants
- Variables
- func Completion(completion string) (string, error)
- func FilterOutInternal(task *ast.Task) bool
- func FilterOutNoDesc(task *ast.Task) bool
- func InitTaskfile(path string) (string, error)
- func ShouldIgnoreFile(path string) bool
- type Call
- type Compiler
- func (c *Compiler) FastGetVariables(t *ast.Task, call *Call) (*ast.Vars, error)
- func (c *Compiler) GetTaskfileVariables() (*ast.Vars, error)
- func (c *Compiler) GetVariables(t *ast.Task, call *Call) (*ast.Vars, error)
- func (c *Compiler) HandleDynamicVar(v ast.Var, dir string, e []string) (string, error)
- func (c *Compiler) ResetCache()
- type Executor
- func (e *Executor) CompiledTask(call *Call) (*ast.Task, error)
- func (e *Executor) FastCompiledTask(call *Call) (*ast.Task, error)
- func (e *Executor) FindMatchingTasks(call *Call) []*MatchingTask
- func (e *Executor) GetHash(t *ast.Task) (string, error)
- func (e *Executor) GetTask(call *Call) (*ast.Task, error)
- func (e *Executor) GetTaskList(filters ...FilterFunc) ([]*ast.Task, error)
- func (e *Executor) InterceptInterruptSignals()
- func (e *Executor) ListTaskNames(allTasks bool) error
- func (e *Executor) ListTasks(o ListOptions) (bool, error)
- func (e *Executor) Options(opts ...ExecutorOption)
- func (e *Executor) Run(ctx context.Context, calls ...*Call) error
- func (e *Executor) RunTask(ctx context.Context, call *Call) error
- func (e *Executor) Setup() error
- func (e *Executor) Status(ctx context.Context, calls ...*Call) error
- func (e *Executor) ToEditorOutput(tasks []*ast.Task, noStatus bool) (*editors.Taskfile, error)
- type ExecutorOption
- func WithAssumeTerm(assumeTerm bool) ExecutorOption
- func WithAssumeYes(assumeYes bool) ExecutorOption
- func WithCacheExpiryDuration(duration time.Duration) ExecutorOption
- func WithColor(color bool) ExecutorOption
- func WithConcurrency(concurrency int) ExecutorOption
- func WithDir(dir string) ExecutorOption
- func WithDownload(download bool) ExecutorOption
- func WithDry(dry bool) ExecutorOption
- func WithEntrypoint(entrypoint string) ExecutorOption
- func WithForce(force bool) ExecutorOption
- func WithForceAll(forceAll bool) ExecutorOption
- func WithIO(rw io.ReadWriter) ExecutorOption
- func WithInsecure(insecure bool) ExecutorOption
- func WithInterval(interval time.Duration) ExecutorOption
- func WithOffline(offline bool) ExecutorOption
- func WithOutputStyle(outputStyle ast.Output) ExecutorOption
- func WithParallel(parallel bool) ExecutorOption
- func WithSilent(silent bool) ExecutorOption
- func WithStderr(stderr io.Writer) ExecutorOption
- func WithStdin(stdin io.Reader) ExecutorOption
- func WithStdout(stdout io.Writer) ExecutorOption
- func WithSummary(summary bool) ExecutorOption
- func WithTaskSorter(sorter sort.Sorter) ExecutorOption
- func WithTempDir(tempDir TempDir) ExecutorOption
- func WithTimeout(timeout time.Duration) ExecutorOption
- func WithVerbose(verbose bool) ExecutorOption
- func WithVersionCheck(enableVersionCheck bool) ExecutorOption
- func WithWatch(watch bool) ExecutorOption
- type FilterFunc
- type ListOptions
- type MatchingTask
- type TempDir
Constants ¶
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 ¶
var DefaultTaskfile string
var ErrPreconditionFailed = errors.New("task: precondition not met")
ErrPreconditionFailed is returned when a precondition fails
Functions ¶
func Completion ¶ added in v3.39.0
func FilterOutInternal ¶ added in v3.18.0
FilterOutInternal removes all tasks that are marked as internal.
func FilterOutNoDesc ¶ added in v3.18.0
FilterOutNoDesc removes all tasks that do not contain a description.
func InitTaskfile ¶
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
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 (*Compiler) GetTaskfileVariables ¶ added in v3.42.0
func (*Compiler) GetVariables ¶ added in v3.42.0
func (*Compiler) HandleDynamicVar ¶ added in v3.42.0
func (*Compiler) ResetCache ¶ added in v3.42.0
func (c *Compiler) ResetCache()
ResetCache clear the dynamic variables cache
type Executor ¶
type Executor struct { // Flags Dir string Entrypoint string TempDir TempDir Force bool ForceAll bool Insecure bool Download bool Offline bool Timeout time.Duration CacheExpiryDuration 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 // I/O Stdin io.Reader Stdout io.Writer Stderr io.Writer // Internal Taskfile *ast.Taskfile Logger *logger.Logger Compiler *Compiler Output output.Output OutputStyle ast.Output TaskSorter sort.Sorter UserWorkingDir string EnableVersionCheck bool // contains filtered or unexported fields }
An Executor is used for processing Taskfile(s) and executing the task(s) within them.
func NewExecutor ¶ added in v3.43.0
func NewExecutor(opts ...ExecutorOption) *Executor
NewExecutor creates a new Executor and applies the given functional options to it.
func (*Executor) CompiledTask ¶
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
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) GetTask ¶ added in v3.17.0
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
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) Options ¶ added in v3.43.0
func (e *Executor) Options(opts ...ExecutorOption)
Options loops through the given ExecutorOption functions and applies them to the Executor.
type ExecutorOption ¶ added in v3.43.0
type ExecutorOption interface {
ApplyToExecutor(*Executor)
}
An ExecutorOption is any type that can apply a configuration to an Executor.
func WithAssumeTerm ¶ added in v3.43.0
func WithAssumeTerm(assumeTerm bool) ExecutorOption
WithAssumeTerm is used for testing purposes to simulate a terminal.
func WithAssumeYes ¶ added in v3.43.0
func WithAssumeYes(assumeYes bool) ExecutorOption
WithAssumeYes tells the Executor to assume "yes" for all prompts.
func WithCacheExpiryDuration ¶ added in v3.43.0
func WithCacheExpiryDuration(duration time.Duration) ExecutorOption
WithCacheExpiryDuration sets the duration after which the cache is considered expired. By default, the cache is considered expired after 24 hours.
func WithColor ¶ added in v3.43.0
func WithColor(color bool) ExecutorOption
WithColor tells the Executor whether or not to output using colorized strings.
func WithConcurrency ¶ added in v3.43.0
func WithConcurrency(concurrency int) ExecutorOption
WithConcurrency sets the maximum number of tasks that the Executor can run in parallel.
func WithDir ¶ added in v3.43.0
func WithDir(dir string) ExecutorOption
WithDir sets the working directory of the Executor. By default, the directory is set to the user's current working directory.
func WithDownload ¶ added in v3.43.0
func WithDownload(download bool) ExecutorOption
WithDownload forces the Executor to download a fresh copy of the taskfile from the remote source.
func WithDry ¶ added in v3.43.0
func WithDry(dry bool) ExecutorOption
WithDry tells the Executor to output the commands that would be run without actually running them.
func WithEntrypoint ¶ added in v3.43.0
func WithEntrypoint(entrypoint string) ExecutorOption
WithEntrypoint sets the entrypoint (main Taskfile) of the Executor. By default, Task will search for one of the default Taskfiles in the given directory.
func WithForce ¶ added in v3.43.0
func WithForce(force bool) ExecutorOption
WithForce ensures that the Executor always runs a task, even when fingerprinting or prompts would normally stop it.
func WithForceAll ¶ added in v3.43.0
func WithForceAll(forceAll bool) ExecutorOption
WithForceAll ensures that the Executor always runs all tasks (including subtasks), even when fingerprinting or prompts would normally stop them.
func WithIO ¶ added in v3.43.0
func WithIO(rw io.ReadWriter) ExecutorOption
WithIO sets the Executor's standard input, output, and error to the same io.ReadWriter.
func WithInsecure ¶ added in v3.43.0
func WithInsecure(insecure bool) ExecutorOption
WithInsecure allows the Executor to make insecure connections when reading remote taskfiles. By default, insecure connections are rejected.
func WithInterval ¶ added in v3.43.0
func WithInterval(interval time.Duration) ExecutorOption
WithInterval sets the interval at which the Executor will wait for duplicated events before running a task.
func WithOffline ¶ added in v3.43.0
func WithOffline(offline bool) ExecutorOption
WithOffline stops the Executor from being able to make network connections. It will still be able to read local files and cached copies of remote files.
func WithOutputStyle ¶ added in v3.43.0
func WithOutputStyle(outputStyle ast.Output) ExecutorOption
WithOutputStyle sets the output style of the Executor. By default, the output style is set to the style defined in the Taskfile.
func WithParallel ¶ added in v3.43.0
func WithParallel(parallel bool) ExecutorOption
WithParallel tells the Executor to run tasks given in the same call in parallel.
func WithSilent ¶ added in v3.43.0
func WithSilent(silent bool) ExecutorOption
WithSilent tells the Executor to suppress all output except for the output of the tasks that are run.
func WithStderr ¶ added in v3.43.0
func WithStderr(stderr io.Writer) ExecutorOption
func WithStdin ¶ added in v3.43.0
func WithStdin(stdin io.Reader) ExecutorOption
func WithStdout ¶ added in v3.43.0
func WithStdout(stdout io.Writer) ExecutorOption
func WithSummary ¶ added in v3.43.0
func WithSummary(summary bool) ExecutorOption
WithSummary tells the Executor to output a summary of the given tasks instead of running them.
func WithTaskSorter ¶ added in v3.43.0
func WithTaskSorter(sorter sort.Sorter) ExecutorOption
WithTaskSorter sets the sorter that the Executor will use to sort tasks. By default, the sorter is set to sort tasks alphabetically, but with tasks with no namespace (in the root Taskfile) first.
func WithTempDir ¶ added in v3.43.0
func WithTempDir(tempDir TempDir) ExecutorOption
WithTempDir sets the temporary directory that will be used by Executor for storing temporary files like checksums and cached remote files. By default, the temporary directory is set to the user's temporary directory.
func WithTimeout ¶ added in v3.43.0
func WithTimeout(timeout time.Duration) ExecutorOption
WithTimeout sets the Executor's timeout for fetching remote taskfiles. By default, the timeout is set to 10 seconds.
func WithVerbose ¶ added in v3.43.0
func WithVerbose(verbose bool) ExecutorOption
WithVerbose tells the Executor to output more information about the tasks that are run.
func WithVersionCheck ¶ added in v3.43.0
func WithVersionCheck(enableVersionCheck bool) ExecutorOption
WithVersionCheck tells the Executor whether or not to check the version of
func WithWatch ¶ added in v3.43.0
func WithWatch(watch bool) ExecutorOption
WithWatch tells the Executor to keep running in the background and watch for changes to the fingerprint of the tasks that are run. When changes are detected, a new task run is triggered.
type FilterFunc ¶ added in v3.18.0
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
type MatchingTask ¶ added in v3.42.0
MatchingTask represents a task that matches a given call. It includes the task itself and a list of wildcards that were matched.