ast

package
v3.41.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2025 License: MIT Imports: 18 Imported by: 2

Documentation

Index

Constants

View Source
const NamespaceSeparator = ":"

NamespaceSeparator contains the character that separates namespaces

Variables

View Source
var ErrIncludedTaskfilesCantHaveDotenvs = errors.New("task: Included Taskfiles can't have dotenv declarations. Please, move the dotenv declaration to the main Taskfile")

ErrIncludedTaskfilesCantHaveDotenvs is returned when a included Taskfile contains dotenvs

View Source
var V3 = semver.MustParse("3")

Functions

This section is empty.

Types

type Call

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

Call is the parameters to a task call

type Cmd

type Cmd struct {
	Cmd         string
	Task        string
	For         *For
	Silent      bool
	Set         []string
	Shopt       []string
	Vars        *Vars
	IgnoreError bool
	Defer       bool
	Platforms   []*Platform
}

Cmd is a task command

func (*Cmd) DeepCopy

func (c *Cmd) DeepCopy() *Cmd

func (*Cmd) UnmarshalYAML

func (c *Cmd) UnmarshalYAML(node *yaml.Node) error

type Dep

type Dep struct {
	Task   string
	For    *For
	Vars   *Vars
	Silent bool
}

Dep is a task dependency

func (*Dep) DeepCopy

func (d *Dep) DeepCopy() *Dep

func (*Dep) UnmarshalYAML

func (d *Dep) UnmarshalYAML(node *yaml.Node) error

type ErrInvalidPlatform

type ErrInvalidPlatform struct {
	Platform string
}

func (*ErrInvalidPlatform) Error

func (err *ErrInvalidPlatform) Error() string

type For

type For struct {
	From   string
	List   []any
	Matrix *Matrix
	Var    string
	Split  string
	As     string
}

func (*For) DeepCopy

func (f *For) DeepCopy() *For

func (*For) UnmarshalYAML

func (f *For) UnmarshalYAML(node *yaml.Node) error

type Glob

type Glob struct {
	Glob   string
	Negate bool
}

func (*Glob) UnmarshalYAML

func (g *Glob) UnmarshalYAML(node *yaml.Node) error

type Include

type Include struct {
	Namespace      string
	Taskfile       string
	Dir            string
	Optional       bool
	Internal       bool
	Aliases        []string
	Excludes       []string
	AdvancedImport bool
	Vars           *Vars
	Flatten        bool
}

Include represents information about included taskfiles

func (*Include) DeepCopy

func (include *Include) DeepCopy() *Include

DeepCopy creates a new instance of IncludedTaskfile and copies data by value from the source struct.

func (*Include) UnmarshalYAML

func (include *Include) UnmarshalYAML(node *yaml.Node) error

type IncludeElement added in v3.41.0

type IncludeElement orderedmap.Element[string, *Include]

An IncludeElement is a key-value pair that is used for initializing an Includes structure.

type Includes

type Includes struct {
	// contains filtered or unexported fields
}

Includes is an ordered map of namespaces to includes.

func NewIncludes added in v3.41.0

func NewIncludes(els ...*IncludeElement) *Includes

NewIncludes creates a new instance of Includes and initializes it with the provided set of elements, if any. The elements are added in the order they are passed.

func (*Includes) Get added in v3.41.0

func (includes *Includes) Get(key string) (*Include, bool)

Get returns the value the the include with the provided key and a boolean that indicates if the value was found or not. If the value is not found, the returned include is a zero value and the bool is false.

func (*Includes) Len

func (includes *Includes) Len() int

Len returns the number of includes in the Includes map.

func (*Includes) Range

func (includes *Includes) Range(f func(k string, v *Include) error) error

Range calls the provided function for each include in the map. The function receives the include's key and value as arguments. If the function returns an error, the iteration stops and the error is returned.

func (*Includes) Set added in v3.41.0

func (includes *Includes) Set(key string, value *Include) bool

Set sets the value of the include with the provided key to the provided value. If the include already exists, its value is updated. If the include does not exist, it is created.

func (*Includes) UnmarshalYAML

func (includes *Includes) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface.

type Location

type Location struct {
	Line     int
	Column   int
	Taskfile string
}

func (*Location) DeepCopy

func (l *Location) DeepCopy() *Location

type MatchingTask added in v3.35.0

type MatchingTask struct {
	Task      *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 Matrix added in v3.41.0

type Matrix struct {
	// contains filtered or unexported fields
}

func NewMatrix added in v3.41.0

func NewMatrix(els ...*MatrixElement) *Matrix

func (*Matrix) DeepCopy added in v3.41.0

func (matrix *Matrix) DeepCopy() *Matrix

func (*Matrix) Get added in v3.41.0

func (matrix *Matrix) Get(key string) ([]any, bool)

func (*Matrix) Len added in v3.41.0

func (matrix *Matrix) Len() int

func (*Matrix) Range added in v3.41.0

func (matrix *Matrix) Range(f func(k string, v []any) error) error

func (*Matrix) Set added in v3.41.0

func (matrix *Matrix) Set(key string, value []any) bool

func (*Matrix) UnmarshalYAML added in v3.41.0

func (matrix *Matrix) UnmarshalYAML(node *yaml.Node) error

type MatrixElement added in v3.41.0

type MatrixElement orderedmap.Element[string, []any]

type Output

type Output struct {
	// Name of the Output.
	Name string `yaml:"-"`
	// Group specific style
	Group OutputGroup
}

Output of the Task output

func (*Output) IsSet

func (s *Output) IsSet() bool

IsSet returns true if and only if a custom output style is set.

func (*Output) UnmarshalYAML

func (s *Output) UnmarshalYAML(node *yaml.Node) error

type OutputGroup

type OutputGroup struct {
	Begin, End string
	ErrorOnly  bool `yaml:"error_only"`
}

OutputGroup is the style options specific to the Group style.

func (*OutputGroup) IsSet

func (g *OutputGroup) IsSet() bool

IsSet returns true if and only if a custom output style is set.

type Platform

type Platform struct {
	OS   string
	Arch string
}

Platform represents GOOS and GOARCH values

func (*Platform) DeepCopy

func (p *Platform) DeepCopy() *Platform

func (*Platform) UnmarshalYAML

func (p *Platform) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface.

type Precondition

type Precondition struct {
	Sh  string
	Msg string
}

Precondition represents a precondition necessary for a task to run

func (*Precondition) DeepCopy

func (p *Precondition) DeepCopy() *Precondition

func (*Precondition) UnmarshalYAML

func (p *Precondition) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface.

type Prompt added in v3.40.0

type Prompt []string

func (*Prompt) UnmarshalYAML added in v3.40.0

func (p *Prompt) UnmarshalYAML(node *yaml.Node) error

type Requires

type Requires struct {
	Vars []*VarsWithValidation
}

Requires represents a set of required variables necessary for a task to run

func (*Requires) DeepCopy

func (r *Requires) DeepCopy() *Requires

type Task

type Task struct {
	Task          string
	Cmds          []*Cmd
	Deps          []*Dep
	Label         string
	Desc          string
	Prompt        Prompt
	Summary       string
	Requires      *Requires
	Aliases       []string
	Sources       []*Glob
	Generates     []*Glob
	Status        []string
	Preconditions []*Precondition
	Dir           string
	Set           []string
	Shopt         []string
	Vars          *Vars
	Env           *Vars
	Dotenv        []string
	Silent        bool
	Interactive   bool
	Internal      bool
	Method        string
	Prefix        string
	IgnoreError   bool
	Run           string
	Platforms     []*Platform
	Watch         bool
	Location      *Location
	// Populated during merging
	Namespace            string
	IncludeVars          *Vars
	IncludedTaskfileVars *Vars
}

Task represents a task

func (*Task) DeepCopy

func (t *Task) DeepCopy() *Task

DeepCopy creates a new instance of Task and copies data by value from the source struct.

func (*Task) LocalName added in v3.38.0

func (t *Task) LocalName() string

func (*Task) Name

func (t *Task) Name() string

func (*Task) UnmarshalYAML

func (t *Task) UnmarshalYAML(node *yaml.Node) error

func (*Task) WildcardMatch added in v3.35.0

func (t *Task) WildcardMatch(name string) (bool, []string)

WildcardMatch will check if the given string matches the name of the Task and returns any wildcard values.

type TaskElement added in v3.41.0

type TaskElement orderedmap.Element[string, *Task]

A TaskElement is a key-value pair that is used for initializing a Tasks structure.

type Taskfile

type Taskfile struct {
	Location string
	Version  *semver.Version
	Output   Output
	Method   string
	Includes *Includes
	Set      []string
	Shopt    []string
	Vars     *Vars
	Env      *Vars
	Tasks    *Tasks
	Silent   bool
	Dotenv   []string
	Run      string
	Interval time.Duration
}

Taskfile is the abstract syntax tree for a Taskfile

func (*Taskfile) Merge

func (t1 *Taskfile) Merge(t2 *Taskfile, include *Include) error

Merge merges the second Taskfile into the first

func (*Taskfile) UnmarshalYAML

func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error

type TaskfileGraph added in v3.37.0

type TaskfileGraph struct {
	sync.Mutex
	graph.Graph[string, *TaskfileVertex]
}

func NewTaskfileGraph added in v3.37.0

func NewTaskfileGraph() *TaskfileGraph

func (*TaskfileGraph) Merge added in v3.37.0

func (tfg *TaskfileGraph) Merge() (*Taskfile, error)

func (*TaskfileGraph) Visualize added in v3.37.0

func (tfg *TaskfileGraph) Visualize(filename string) error

type TaskfileVertex added in v3.37.0

type TaskfileVertex struct {
	URI      string
	Taskfile *Taskfile
}

A TaskfileVertex is a vertex on the Taskfile DAG.

type Tasks

type Tasks struct {
	// contains filtered or unexported fields
}

Tasks is an ordered map of task names to Tasks.

func NewTasks added in v3.41.0

func NewTasks(els ...*TaskElement) *Tasks

NewTasks creates a new instance of Tasks and initializes it with the provided set of elements, if any. The elements are added in the order they are passed.

func (*Tasks) FindMatchingTasks added in v3.35.0

func (t *Tasks) 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 (*Tasks) Get added in v3.41.0

func (tasks *Tasks) Get(key string) (*Task, bool)

Get returns the value the the task with the provided key and a boolean that indicates if the value was found or not. If the value is not found, the returned task is a zero value and the bool is false.

func (*Tasks) Keys added in v3.41.0

func (tasks *Tasks) Keys() []string

Keys returns a slice of all the keys in the Tasks map.

func (*Tasks) Len added in v3.41.0

func (tasks *Tasks) Len() int

Len returns the number of variables in the Tasks map.

func (*Tasks) Merge

func (t1 *Tasks) Merge(t2 *Tasks, include *Include, includedTaskfileVars *Vars) error

func (*Tasks) Range added in v3.41.0

func (tasks *Tasks) Range(f func(k string, v *Task) error) error

Range calls the provided function for each task in the map. The function receives the task's key and value as arguments. If the function returns an error, the iteration stops and the error is returned.

func (*Tasks) Set added in v3.41.0

func (tasks *Tasks) Set(key string, value *Task) bool

Set sets the value of the task with the provided key to the provided value. If the task already exists, its value is updated. If the task does not exist, it is created.

func (*Tasks) UnmarshalYAML

func (t *Tasks) UnmarshalYAML(node *yaml.Node) error

func (*Tasks) Values added in v3.41.0

func (tasks *Tasks) Values() []*Task

Values returns a slice of all the values in the Tasks map.

type Var

type Var struct {
	Value any
	Live  any
	Sh    *string
	Ref   string
	Dir   string
}

Var represents either a static or dynamic variable.

func (*Var) UnmarshalYAML

func (v *Var) UnmarshalYAML(node *yaml.Node) error

type VarElement added in v3.41.0

type VarElement orderedmap.Element[string, Var]

A VarElement is a key-value pair that is used for initializing a Vars structure.

type Vars

type Vars struct {
	// contains filtered or unexported fields
}

Vars is an ordered map of variable names to values.

func NewVars added in v3.41.0

func NewVars(els ...*VarElement) *Vars

NewVars creates a new instance of Vars and initializes it with the provided set of elements, if any. The elements are added in the order they are passed.

func (*Vars) DeepCopy

func (vs *Vars) DeepCopy() *Vars

func (*Vars) Get added in v3.41.0

func (vars *Vars) Get(key string) (Var, bool)

Get returns the value the the variable with the provided key and a boolean that indicates if the value was found or not. If the value is not found, the returned variable is a zero value and the bool is false.

func (*Vars) Len

func (vars *Vars) Len() int

Len returns the number of variables in the Vars map.

func (*Vars) Merge

func (vars *Vars) Merge(other *Vars, include *Include)

Merge loops over other and merges it values with the variables in vars. If the include parameter is not nil and its it is an advanced import, the directory is set set to the value of the include parameter.

func (*Vars) Range

func (vars *Vars) Range(f func(k string, v Var) error) error

Range calls the provided function for each variable in the map. The function receives the variable's key and value as arguments. If the function returns an error, the iteration stops and the error is returned.

func (*Vars) Set added in v3.41.0

func (vars *Vars) Set(key string, value Var) bool

Set sets the value of the variable with the provided key to the provided value. If the variable already exists, its value is updated. If the variable does not exist, it is created.

func (*Vars) ToCacheMap

func (vars *Vars) ToCacheMap() (m map[string]any)

ToCacheMap converts Vars to an unordered map containing only the static variables

func (*Vars) UnmarshalYAML added in v3.41.0

func (vs *Vars) UnmarshalYAML(node *yaml.Node) error

type VarsWithValidation added in v3.40.0

type VarsWithValidation struct {
	Name string
	Enum []string
}

func (*VarsWithValidation) DeepCopy added in v3.40.0

func (v *VarsWithValidation) DeepCopy() *VarsWithValidation

func (*VarsWithValidation) UnmarshalYAML added in v3.40.0

func (v *VarsWithValidation) UnmarshalYAML(node *yaml.Node) error

UnmarshalYAML implements yaml.Unmarshaler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳