taskfile

package
v3.43.3-stable Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2025 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dotenv

func Dotenv(vars *ast.Vars, tf *ast.Taskfile, dir string) (*ast.Vars, error)

func NewBaseNode

func NewBaseNode(dir string, opts ...NodeOption) *baseNode

func RemoteExists

func RemoteExists(ctx context.Context, u url.URL) (*url.URL, error)

RemoteExists will check if a file at the given URL Exists. If it does, it will return its URL. If it does not, it will search the search for any files at the given URL with any of the default Taskfile files names. If any of these match a file, the first matching path will be returned. If no files are found, an error will be returned.

Types

type CacheNode

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

func NewCacheNode

func NewCacheNode(source RemoteNode, dir string) *CacheNode

func (CacheNode) Checksum

func (node CacheNode) Checksum() string

func (*CacheNode) ChecksumPrompt

func (node *CacheNode) ChecksumPrompt(checksum string) string

func (*CacheNode) CreateCacheDir

func (node *CacheNode) CreateCacheDir() error

func (CacheNode) Dir

func (node CacheNode) Dir() string

func (*CacheNode) Location

func (node *CacheNode) Location() string

func (CacheNode) Parent

func (node CacheNode) Parent() Node

func (*CacheNode) Read

func (node *CacheNode) Read() ([]byte, error)

func (*CacheNode) ReadChecksum

func (node *CacheNode) ReadChecksum() string

func (*CacheNode) ReadTimestamp

func (node *CacheNode) ReadTimestamp() time.Time

func (CacheNode) Verify

func (node CacheNode) Verify(checksum string) bool

func (*CacheNode) Write

func (node *CacheNode) Write(data []byte) error

func (*CacheNode) WriteChecksum

func (node *CacheNode) WriteChecksum(checksum string) error

func (*CacheNode) WriteTimestamp

func (node *CacheNode) WriteTimestamp(t time.Time) error

type DebugFunc

type DebugFunc func(string)

DebugFunc is a function that can be called to log debug messages.

type FileNode

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

A FileNode is a node that reads a taskfile from the local filesystem.

func NewFileNode

func NewFileNode(entrypoint, dir string, opts ...NodeOption) (*FileNode, error)

func (FileNode) Checksum

func (node FileNode) Checksum() string

func (FileNode) Dir

func (node FileNode) Dir() string

func (*FileNode) Location

func (node *FileNode) Location() string

func (FileNode) Parent

func (node FileNode) Parent() Node

func (*FileNode) Read

func (node *FileNode) Read() ([]byte, error)

func (*FileNode) ResolveDir

func (node *FileNode) ResolveDir(dir string) (string, error)

func (*FileNode) ResolveEntrypoint

func (node *FileNode) ResolveEntrypoint(entrypoint string) (string, error)

func (FileNode) Verify

func (node FileNode) Verify(checksum string) bool

type GitNode

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

An GitNode is a node that reads a Taskfile from a remote location via Git.

func NewGitNode

func NewGitNode(
	entrypoint string,
	dir string,
	insecure bool,
	opts ...NodeOption,
) (*GitNode, error)

func (*GitNode) CacheKey

func (node *GitNode) CacheKey() string

func (GitNode) Checksum

func (node GitNode) Checksum() string

func (GitNode) Dir

func (node GitNode) Dir() string

func (*GitNode) Location

func (node *GitNode) Location() string

func (GitNode) Parent

func (node GitNode) Parent() Node

func (*GitNode) Read

func (node *GitNode) Read() ([]byte, error)

func (*GitNode) ReadContext

func (node *GitNode) ReadContext(_ context.Context) ([]byte, error)

func (*GitNode) Remote

func (node *GitNode) Remote() bool

func (*GitNode) ResolveDir

func (node *GitNode) ResolveDir(dir string) (string, error)

func (*GitNode) ResolveEntrypoint

func (node *GitNode) ResolveEntrypoint(entrypoint string) (string, error)

func (GitNode) Verify

func (node GitNode) Verify(checksum string) bool

type HTTPNode

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

An HTTPNode is a node that reads a Taskfile from a remote location via HTTP.

func NewHTTPNode

func NewHTTPNode(
	entrypoint string,
	dir string,
	insecure bool,
	opts ...NodeOption,
) (*HTTPNode, error)

func (*HTTPNode) CacheKey

func (node *HTTPNode) CacheKey() string

func (HTTPNode) Checksum

func (node HTTPNode) Checksum() string

func (HTTPNode) Dir

func (node HTTPNode) Dir() string

func (*HTTPNode) Location

func (node *HTTPNode) Location() string

func (HTTPNode) Parent

func (node HTTPNode) Parent() Node

func (*HTTPNode) Read

func (node *HTTPNode) Read() ([]byte, error)

func (*HTTPNode) ReadContext

func (node *HTTPNode) ReadContext(ctx context.Context) ([]byte, error)

func (*HTTPNode) ResolveDir

func (node *HTTPNode) ResolveDir(dir string) (string, error)

func (*HTTPNode) ResolveEntrypoint

func (node *HTTPNode) ResolveEntrypoint(entrypoint string) (string, error)

func (HTTPNode) Verify

func (node HTTPNode) Verify(checksum string) bool

type Node

type Node interface {
	Read() ([]byte, error)
	Parent() Node
	Location() string
	Dir() string
	Checksum() string
	Verify(checksum string) bool
	ResolveEntrypoint(entrypoint string) (string, error)
	ResolveDir(dir string) (string, error)
}

func NewNode

func NewNode(
	entrypoint string,
	dir string,
	insecure bool,
	opts ...NodeOption,
) (Node, error)

func NewRootNode

func NewRootNode(
	entrypoint string,
	dir string,
	insecure bool,
	timeout time.Duration,
) (Node, error)

type NodeOption

type NodeOption func(*baseNode)

func WithChecksum

func WithChecksum(checksum string) NodeOption

func WithParent

func WithParent(parent Node) NodeOption

type PromptFunc

type PromptFunc func(string) error

PromptFunc is a function that can be called to prompt the user for input.

type Reader

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

A Reader will recursively read Taskfiles from a given Node and build a ast.TaskfileGraph from them.

func NewReader

func NewReader(opts ...ReaderOption) *Reader

NewReader constructs a new Taskfile Reader using the given Node and options.

func (*Reader) Options

func (r *Reader) Options(opts ...ReaderOption)

Options loops through the given ReaderOption functions and applies them to the Reader.

func (*Reader) Read

func (r *Reader) Read(ctx context.Context, node Node) (*ast.TaskfileGraph, error)

Read will read the Taskfile defined by the Reader's Node and recurse through any ast.Includes it finds, reading each included Taskfile and building an ast.TaskfileGraph as it goes. If any errors occur, they will be returned immediately.

type ReaderOption

type ReaderOption interface {
	ApplyToReader(*Reader)
}

A ReaderOption is any type that can apply a configuration to a Reader.

func WithCacheExpiryDuration

func WithCacheExpiryDuration(duration time.Duration) ReaderOption

WithCacheExpiryDuration sets the duration after which the cache is considered expired. By default, the cache is considered expired after 24 hours.

func WithDebugFunc

func WithDebugFunc(debugFunc DebugFunc) ReaderOption

WithDebugFunc sets the debug function to be used by the Reader. If set, this function will be called with debug messages. This can be useful if the caller wants to log debug messages from the Reader. By default, no debug function is set and the logs are not written.

func WithDownload

func WithDownload(download bool) ReaderOption

WithDownload forces the Reader to download a fresh copy of the taskfile from the remote source.

func WithInsecure

func WithInsecure(insecure bool) ReaderOption

WithInsecure allows the Reader to make insecure connections when reading remote taskfiles. By default, insecure connections are rejected.

func WithOffline

func WithOffline(offline bool) ReaderOption

WithOffline stops the Reader from being able to make network connections. It will still be able to read local files and cached copies of remote files.

func WithPromptFunc

func WithPromptFunc(promptFunc PromptFunc) ReaderOption

WithPromptFunc sets the prompt function to be used by the Reader. If set, this function will be called with prompt messages. The function should optionally log the message to the user and return nil if the prompt is accepted and the execution should continue. Otherwise, it should return an error which describes why the prompt was rejected. This can then be caught and used later when calling the Reader.Read method. By default, no prompt function is set and all prompts are automatically accepted.

func WithTempDir

func WithTempDir(tempDir string) ReaderOption

WithTempDir sets the temporary directory that will be used by the Reader. By default, the reader uses os.TempDir.

type RemoteNode

type RemoteNode interface {
	Node
	ReadContext(ctx context.Context) ([]byte, error)
	CacheKey() string
}

type Snippet

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

A Snippet is a syntax highlighted snippet of a Taskfile with optional padding and a line and column indicator.

func NewSnippet

func NewSnippet(b []byte, opts ...SnippetOption) *Snippet

NewSnippet creates a new Snippet from a byte slice and a line and column number. The line and column numbers should be 1-indexed. For example, the first character in the file would be 1:1 (line 1, column 1). The padding determines the number of lines to include before and after the chosen line.

func (*Snippet) Options

func (s *Snippet) Options(opts ...SnippetOption)

Options loops through the given SnippetOption functions and applies them to the Snippet.

func (*Snippet) String

func (s *Snippet) String() string

type SnippetOption

type SnippetOption interface {
	ApplyToSnippet(*Snippet)
}

A SnippetOption is any type that can apply a configuration to a Snippet.

func WithColumn

func WithColumn(column int) SnippetOption

WithColumn specifies the column number that the Snippet should point to.

func WithLine

func WithLine(line int) SnippetOption

WithLine specifies the line number that the Snippet should center around and point to.

func WithNoIndicators

func WithNoIndicators() SnippetOption

WithNoIndicators specifies that the Snippet should not include line or column indicators.

func WithPadding

func WithPadding(padding int) SnippetOption

WithPadding specifies the number of lines to include before and after the selected line in the Snippet.

type StdinNode

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

A StdinNode is a node that reads a taskfile from the standard input stream.

func NewStdinNode

func NewStdinNode(dir string) (*StdinNode, error)

func (StdinNode) Checksum

func (node StdinNode) Checksum() string

func (StdinNode) Dir

func (node StdinNode) Dir() string

func (*StdinNode) Location

func (node *StdinNode) Location() string

func (StdinNode) Parent

func (node StdinNode) Parent() Node

func (*StdinNode) Read

func (node *StdinNode) Read() ([]byte, error)

func (*StdinNode) Remote

func (node *StdinNode) Remote() bool

func (*StdinNode) ResolveDir

func (node *StdinNode) ResolveDir(dir string) (string, error)

func (*StdinNode) ResolveEntrypoint

func (node *StdinNode) ResolveEntrypoint(entrypoint string) (string, error)

func (StdinNode) Verify

func (node StdinNode) Verify(checksum string) bool

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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