Documentation
¶
Index ¶
- func FindRootDir(dir string) (string, error)
- func IsInternalTask(name string) bool
- type Cmd
- type Config
- type Dep
- type Execution
- type Precondition
- type Requires
- type Runner
- type RunnerIO
- type ShellCommand
- type ShellCommandKind
- type ShellRunner
- type StringList
- type Task
- type TaskNotFoundError
- type Var
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindRootDir ¶
FindRootDir walks up from dir to find the nearest directory containing a gogo.yaml.
func IsInternalTask ¶ added in v1.0.2
IsInternalTask reports whether a task name is internal (its local segment starts with '_'). Only the part after the last colon is checked so 'ns:_helper' is internal but 'ns:public' is not. Internal tasks are hidden from --list, completion, and prefix matching.
Types ¶
type Cmd ¶
type Cmd struct {
Cmd string `yaml:"cmd"`
Task string `yaml:"task"`
Vars map[string]Var `yaml:"vars"`
}
Cmd represents a command in a task. It can be a simple string or a task reference.
type Config ¶
type Config struct {
Version string `yaml:"version"`
Includes []string `yaml:"includes"`
Flatten []string `yaml:"flatten"` // YAML files whose tasks merge into this config without a namespace
Dotenv []string `yaml:"dotenv"`
Default string `yaml:"default"` // task to run when none is given on the CLI; replaces the convention of declaring a `default` task
Vars map[string]Var `yaml:"vars"` // vars declared at the root (namespace "")
Sources map[string]StringList `yaml:"sources"` // named source presets, referenced from task.Sources by name
Secrets map[string]string `yaml:"secrets"` // named secret URIs (op://, aws-creds://, ...), referenced from task.Secrets
Tasks map[string]Task `yaml:"tasks"`
Dir string `yaml:"-"`
Interval string `yaml:"interval"`
Namespaces map[string]string `yaml:"-"` // dir -> namespace
NamespaceDirs map[string]string `yaml:"-"` // namespace -> dir (where each include's gogo.yaml lives, used to resolve `sh:` vars in their own working dir)
NamespaceVars map[string]map[string]Var `yaml:"-"` // namespace -> vars declared at that namespace; not visible to sibling namespaces
DotenvVars map[string]string `yaml:"-"` // resolved dotenv variables
}
Config represents a parsed gogo.yaml.
func LoadWithIncludes ¶
LoadWithIncludes parses a task file and resolves all includes into a flat task map.
type Precondition ¶
Precondition defines a shell command that must succeed before a task runs.
func (*Precondition) UnmarshalYAML ¶
func (p *Precondition) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML allows Precondition to be either a string (shell command) or a map.
type Requires ¶
Requires defines variables and environment variables that must be set for a task to run.
type Runner ¶
type Runner struct {
BaseEnv []string // base process environment (defaults to os.Environ() + dotenv)
DryRun bool // if true, print commands without executing them
Force bool // if true, ignore sources and generates (always run)
ShellRunner ShellRunner // replaceable shell executor (defaults to real exec)
IO RunnerIO // process streams used for logs and command stdio
// contains filtered or unexported fields
}
Runner executes tasks from a loaded task file.
func (*Runner) ResetRan ¶
func (r *Runner) ResetRan()
ResetRan clears the memoized task results, allowing tasks to run again. This is used by watch mode between iterations. Built-in git vars are re-resolved too because file edits between iterations may have changed the working tree's dirty state or HEAD.
type ShellCommand ¶
type ShellCommand struct {
Kind ShellCommandKind
TaskName string
Command string
Dir string
Env []string
UseOpRun bool
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
}
ShellCommand describes one shell invocation.
type ShellCommandKind ¶
type ShellCommandKind string
ShellCommandKind identifies why a shell command is being run.
const ( ShellCommandTask ShellCommandKind = "task" ShellCommandPrecondition ShellCommandKind = "precondition" ShellCommandVar ShellCommandKind = "var" )
type ShellRunner ¶
type ShellRunner interface {
Run(req ShellCommand) error
Output(req ShellCommand) ([]byte, error)
}
ShellRunner runs shell commands for task commands, preconditions, and shell variables.
type StringList ¶
type StringList []string
StringList is a []string that can be unmarshalled from either a single string or a list.
func (*StringList) UnmarshalYAML ¶
func (sl *StringList) UnmarshalYAML(unmarshal func(any) error) error
UnmarshalYAML allows StringList to be either a string or a sequence.
type Task ¶
type Task struct {
Cmds []Cmd `yaml:"cmds"`
Deps []Dep `yaml:"deps"`
Dir string `yaml:"dir"`
Dotenv []string `yaml:"dotenv"`
Env map[string]string `yaml:"env"`
Vars map[string]Var `yaml:"vars"`
Secrets StringList `yaml:"secrets"` // names referencing entries in Config.Secrets
Sources StringList `yaml:"sources"`
Generates StringList `yaml:"generates"`
Aliases StringList `yaml:"aliases"`
Platforms StringList `yaml:"platforms"`
Requires Requires `yaml:"requires"`
Preconditions []Precondition `yaml:"preconditions"`
Silent bool `yaml:"silent"` // when true, suppress the per-cmd "[task] cmd" log line
Desc string `yaml:"-"` // set from YAML comments, not from a field
}
Task represents a single task definition.
type TaskNotFoundError ¶ added in v1.0.3
type TaskNotFoundError struct {
Name string // the unresolved input as typed by the user
Suggestions []string // best-effort 'did you mean' hints (may be empty)
}
TaskNotFoundError is returned when the user asks for a task name that doesn't resolve. It's a typed error so callers (notably the CLI) can react — for example, by printing the task list alongside the message — without parsing the formatted text.
func (*TaskNotFoundError) Error ¶ added in v1.0.3
func (e *TaskNotFoundError) Error() string
Error renders the message historically produced by resolveTask. The exact wording is part of the user-facing contract: tooling and tests grep for 'not found' and 'did you mean'.