Documentation
¶
Index ¶
- Constants
- Variables
- type Cmd
- type Defer
- type Dep
- type Enum
- type ErrInvalidPlatform
- type For
- type Glob
- type Include
- type IncludeElement
- type Includes
- func (includes *Includes) All() iter.Seq2[string, *Include]
- func (includes *Includes) Get(key string) (*Include, bool)
- func (includes *Includes) Keys() iter.Seq[string]
- func (includes *Includes) Len() int
- func (includes *Includes) Set(key string, value *Include) bool
- func (includes *Includes) UnmarshalYAML(node *yaml.Node) error
- func (includes *Includes) Values() iter.Seq[*Include]
- type Location
- type Matrix
- func (matrix *Matrix) All() iter.Seq2[string, *MatrixRow]
- func (matrix *Matrix) DeepCopy() *Matrix
- func (matrix *Matrix) Get(key string) (*MatrixRow, bool)
- func (matrix *Matrix) Keys() iter.Seq[string]
- func (matrix *Matrix) Len() int
- func (matrix *Matrix) Set(key string, value *MatrixRow) bool
- func (matrix *Matrix) UnmarshalYAML(node *yaml.Node) error
- func (matrix *Matrix) Values() iter.Seq[*MatrixRow]
- type MatrixElement
- type MatrixRow
- type Output
- type OutputGroup
- type Platform
- type Precondition
- type Prompt
- type Requires
- type Ritefile
- type RitefileGraph
- type RitefileVertex
- type Task
- type TaskElement
- type Tasks
- func (t *Tasks) All(sorter sort.Sorter) iter.Seq2[string, *Task]
- func (tasks *Tasks) Get(key string) (*Task, bool)
- func (t *Tasks) Keys(sorter sort.Sorter) iter.Seq[string]
- func (tasks *Tasks) Len() int
- func (t1 *Tasks) Merge(t2 *Tasks, include *Include, includedRitefileVars *Vars) error
- func (tasks *Tasks) Set(key string, value *Task) bool
- func (t *Tasks) UnmarshalYAML(node *yaml.Node) error
- func (t *Tasks) Values(sorter sort.Sorter) iter.Seq[*Task]
- type Timestamps
- type Var
- type VarElement
- type Vars
- func (vars *Vars) All() iter.Seq2[string, Var]
- func (vs *Vars) DeepCopy() *Vars
- func (vars *Vars) Get(key string) (Var, bool)
- func (vars *Vars) Keys() iter.Seq[string]
- func (vars *Vars) Len() int
- func (vars *Vars) Merge(other *Vars, include *Include)
- func (vars *Vars) ReverseMerge(other *Vars, include *Include)
- func (vars *Vars) Set(key string, value Var) bool
- func (vars *Vars) ToCacheMap() (m map[string]any)
- func (vs *Vars) UnmarshalYAML(node *yaml.Node) error
- func (vars *Vars) Values() iter.Seq[Var]
- type VarsWithValidation
Constants ¶
const DefaultTimestampLayout = "[2006-01-02T15:04:05.000Z]"
DefaultTimestampLayout is the Go time layout used when `timestamps: true` is set (at any scope). ISO 8601 extended, UTC, zero-padded millisecond precision, square-bracketed so the prefix is visually separable from cmd content. See SPEC §Output Timestamps.
const NamespaceSeparator = ":"
NamespaceSeparator contains the character that separates namespaces
const TimestampMarkerEnvVar = "RITE_TIMESTAMPS_HANDLED"
TimestampMarkerEnvVar is the marker variable rite injects into a cmd's environ whenever its output is being wrapped by a TimestampWriter. A nested rite invocation that sees this variable set to "1" skips its own timestamp wrapping entirely — otherwise every level of nesting would add another prefix and multi-level `rite`-calls-`rite` chains would emit `[ts] [ts] [ts] line`. See SPEC §Output Timestamps / "Nested invocations".
Variables ¶
var ( V3 = semver.MustParse("3") // V4 marks the first unsupported future schema version. `doVersionChecks` // rejects any schema `>= V4` so a Ritefile authored against a future // schema fails loudly on an older rite instead of silently degrading to // v3 semantics — the same fail-loudly philosophy as the v2 rejection // below V3. V4 = semver.MustParse("4") )
var ErrIncludedRitefilesCantHaveDotenvs = errors.New("rite: Included Ritefiles can't have dotenv declarations. Please, move the dotenv declaration to the main Ritefile")
ErrIncludedRitefilesCantHaveDotenvs is returned when an included Ritefile contains dotenvs
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd struct {
Cmd string `yaml:"cmd"`
Task string `yaml:"task"`
For *For `yaml:"for"`
If string `yaml:"if"`
Silent bool `yaml:"silent"`
Set []string `yaml:"set"`
Shopt []string `yaml:"shopt"`
Vars *Vars `yaml:"vars"`
IgnoreError bool `yaml:"ignore_error"`
Defer bool `yaml:"defer"`
Platforms []*Platform `yaml:"platforms"`
}
Cmd is a task command
type Defer ¶
type Dep ¶
type Dep struct {
Task string `yaml:"task"`
For *For `yaml:"for"`
Vars *Vars `yaml:"vars"`
Silent bool `yaml:"silent"`
}
Dep is a task dependency
type Enum ¶
Enum represents an enum constraint for a required variable. It can either be a static list of values or a reference to another variable.
type ErrInvalidPlatform ¶
type ErrInvalidPlatform struct {
Platform string
}
func (*ErrInvalidPlatform) Error ¶
func (err *ErrInvalidPlatform) Error() string
type For ¶
type Include ¶
type Include struct {
Namespace string `yaml:"-"`
Ritefile string `yaml:"taskfile"`
Dir string `yaml:"dir"`
Optional bool `yaml:"optional"`
Internal bool `yaml:"internal"`
Aliases []string `yaml:"aliases"`
Excludes []string `yaml:"excludes"`
AdvancedImport bool `yaml:"-"`
Vars *Vars `yaml:"vars"`
Flatten bool `yaml:"flatten"`
Checksum string `yaml:"checksum"`
}
Include represents information about included taskfiles
type IncludeElement ¶
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 ¶
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) All ¶
All returns an iterator that loops over all task key-value pairs. 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) Get ¶
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) Set ¶
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 ¶
UnmarshalYAML implements the yaml.Unmarshaler interface.
type Matrix ¶
type Matrix struct {
// contains filtered or unexported fields
}
Matrix is an ordered map of variable names to arrays of values.
func NewMatrix ¶
func NewMatrix(els ...*MatrixElement) *Matrix
type MatrixElement ¶
type MatrixElement orderedmap.Element[string, *MatrixRow]
A MatrixElement is a key-value pair that is used for initializing a Matrix structure.
type Output ¶
type Output struct {
// Name of the Output.
Name string `yaml:"-"`
// Group specific style
Group OutputGroup `yaml:"group"`
}
Output of the Task output
type OutputGroup ¶
type OutputGroup struct {
Begin string `yaml:"begin"`
End string `yaml:"end"`
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 Precondition ¶
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 Requires ¶
type Requires struct {
Vars []*VarsWithValidation `yaml:"vars"`
}
Requires represents a set of required variables necessary for a task to run
type Ritefile ¶ added in v1.0.0
type Ritefile struct {
Location string `yaml:"-"`
Version *semver.Version `yaml:"version"`
Output Output `yaml:"output"`
Method string `yaml:"method"`
Includes *Includes `yaml:"includes"`
Set []string `yaml:"set"`
Shopt []string `yaml:"shopt"`
Vars *Vars `yaml:"vars"`
Env *Vars `yaml:"env"`
Tasks *Tasks `yaml:"tasks"`
Silent bool `yaml:"silent"`
Dotenv []string `yaml:"dotenv"`
Run string `yaml:"run"`
Interval time.Duration `yaml:"interval"`
Timestamps *Timestamps `yaml:"timestamps,omitempty"`
}
Ritefile is the abstract syntax tree for a Ritefile
type RitefileGraph ¶ added in v1.0.0
func NewRitefileGraph ¶ added in v1.0.0
func NewRitefileGraph() *RitefileGraph
func (*RitefileGraph) Merge ¶ added in v1.0.0
func (tfg *RitefileGraph) Merge() (*Ritefile, error)
func (*RitefileGraph) Visualize ¶ added in v1.0.0
func (tfg *RitefileGraph) Visualize(filename string) error
type RitefileVertex ¶ added in v1.0.0
A RitefileVertex is a vertex on the Ritefile DAG.
type Task ¶
type Task struct {
Task string `yaml:"-" hash:"ignore"`
Cmds []*Cmd `yaml:"cmds"`
Deps []*Dep `yaml:"deps"`
Label string `yaml:"label"`
Desc string `yaml:"desc"`
Prompt Prompt `yaml:"prompt"`
Summary string `yaml:"summary"`
Requires *Requires `yaml:"requires"`
Aliases []string `yaml:"aliases"`
Sources []*Glob `yaml:"sources"`
Generates []*Glob `yaml:"generates"`
Status []string `yaml:"status"`
Preconditions []*Precondition `yaml:"preconditions"`
Dir string `yaml:"dir"`
Set []string `yaml:"set"`
Shopt []string `yaml:"shopt"`
Vars *Vars `yaml:"vars"`
Env *Vars `yaml:"env"`
Dotenv []string `yaml:"dotenv"`
Silent *bool `yaml:"silent,omitempty"`
Interactive bool `yaml:"interactive"`
Internal bool `yaml:"internal"`
Method string `yaml:"method"`
Prefix string `yaml:"prefix" hash:"ignore"`
IgnoreError bool `yaml:"ignore_error"`
Run string `yaml:"run"`
Platforms []*Platform `yaml:"platforms"`
If string `yaml:"if"`
Watch bool `yaml:"watch"`
Location *Location `yaml:"-"`
Failfast bool `yaml:"failfast"`
Timestamps *Timestamps `yaml:"timestamps,omitempty"`
// Populated during merging
Namespace string `yaml:"-" hash:"ignore"`
IncludeVars *Vars `yaml:"-"`
IncludedRitefileVars *Vars `yaml:"-"`
FullName string `yaml:"-" hash:"ignore"`
}
Task represents a task
func (*Task) DeepCopy ¶
DeepCopy creates a new instance of Task and copies data by value from the source struct.
type TaskElement ¶
type TaskElement orderedmap.Element[string, *Task]
A TaskElement is a key-value pair that is used for initializing a Tasks structure.
type Tasks ¶
type Tasks struct {
// contains filtered or unexported fields
}
Tasks is an ordered map of task names to Tasks.
func NewTasks ¶
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) All ¶
All returns an iterator that loops over all task key-value pairs in the order specified by the sorter.
func (*Tasks) Get ¶
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 ¶
Keys returns an iterator that loops over all task keys in the order specified by the sorter.
type Timestamps ¶ added in v1.0.4
type Timestamps struct {
// Enabled is non-nil when the user explicitly set a value at this scope.
// *Enabled == true means on; *Enabled == false means off.
Enabled *bool
// Format is the optional strftime-style format string. Empty means "use
// the default layout" (when Enabled is *true).
Format string
}
Timestamps is the tri-state value for the `timestamps:` knob at both the entrypoint level and the task level.
- Unset (nil) → inherit from the next-higher scope (or off if top-level). - Explicit `true` → use DefaultTimestampLayout. - Explicit `false` → off (overrides a higher-scope `true`). - Explicit strftime string → use that format.
The value is stored on a pointer so the YAML decoder can distinguish "omitted" (nil) from "false" (present, disabled). A bool-only field cannot express the override-off-a-global-on case.
func (*Timestamps) DeepCopy ¶ added in v1.0.4
func (t *Timestamps) DeepCopy() *Timestamps
DeepCopy returns a deep copy of the Timestamps value, including a fresh pointer for Enabled so callers can mutate one copy without racing the other.
func (*Timestamps) IsSet ¶ added in v1.0.4
func (t *Timestamps) IsSet() bool
IsSet reports whether the user declared a value for this scope.
func (*Timestamps) On ¶ added in v1.0.4
func (t *Timestamps) On() bool
On reports whether timestamps are enabled at this scope. Callers must check IsSet() first — On() on an unset value returns false.
func (*Timestamps) UnmarshalYAML ¶ added in v1.0.4
func (t *Timestamps) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML accepts `true`, `false`, or a strftime string.
type Var ¶
type Var struct {
Value any `yaml:"value"`
Live any `yaml:"-"`
Sh *string `yaml:"sh"`
Ref string `yaml:"ref"`
Dir string `yaml:"-"`
Export *bool `yaml:"export"`
}
Var represents either a static or dynamic variable.
Export controls whether this variable is propagated to cmd shell environments. A nil pointer means "default" — currently equivalent to true. Users opt out of export with `export: false` in the map form (SPEC §vars/env Unification, non-exported variables section).
type VarElement ¶
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 ¶
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) Get ¶
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) Merge ¶
Merge loops over other and merges its values with the variables in vars. If the include parameter is not nil and is an advanced import, the directory is set to the value of the include parameter.
Snapshots `other` under its read lock, then writes into `vars` under its write lock. Holding the two locks disjointly mirrors ReverseMerge and keeps concurrent readers/writers on either side safe — see issue #48. The bug it replaces wrote into vars.om with no lock on vars at all, which went unnoticed because graph.Merge currently serializes the include walk; the moment that parallelism is restored (#49) the racy writes become live.
func (*Vars) ReverseMerge ¶
ReverseMerge merges other variables with the existing variables in vars, but keeps the other variables first in order. If the include parameter is not nil and it is an advanced import, the directory is set to the value of the include parameter.
func (*Vars) Set ¶
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 ¶
ToCacheMap converts Vars to an unordered map containing only the static variables
type VarsWithValidation ¶
func (*VarsWithValidation) DeepCopy ¶
func (v *VarsWithValidation) DeepCopy() *VarsWithValidation
func (*VarsWithValidation) UnmarshalYAML ¶
func (v *VarsWithValidation) UnmarshalYAML(node *yaml.Node) error
UnmarshalYAML implements yaml.Unmarshaler interface.