Go API Documentation

github.com/go-task/task/v3/taskfile

No package summary is available.

Package

Files: 10. Third party imports: 13. Imports from organisation: 0. Tests: 0. Benchmarks: 0.

Constants

Vars

Types

CacheNode

This type doesn't have documentation.

Field name Field type Comment

*baseNode

No comment on field.
source

RemoteNode

No comment on field.

FileNode

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

Field name Field type Comment

*baseNode

No comment on field.
entrypoint

string

No comment on field.

GitNode

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

Field name Field type Comment

*baseNode

No comment on field.
url

*url.URL

No comment on field.
rawUrl

string

No comment on field.
ref

string

No comment on field.
path

string

No comment on field.

HTTPNode

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

Field name Field type Comment

*baseNode

No comment on field.
url

*url.URL

No comment on field.

Node

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.

RemoteNode

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.

StdinNode

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

Field name Field type Comment

*baseNode

No comment on field.

NodeOption, baseNode

This type doesn't have documentation.

Field name Field type Comment
type

func(*baseNode)

No comment on field.
parent

Node

No comment on field.
dir

string

No comment on field.
checksum

string

No comment on field.

DebugFunc, PromptFunc, ReaderOption, Reader

This type doesn't have documentation.

Field name Field type Comment
type

func(string)

No comment on field.
type

func(string) error

No comment on field.
type

any

No comment on field.
graph

*ast.TaskfileGraph

No comment on field.
insecure

bool

No comment on field.
download

bool

No comment on field.
offline

bool

No comment on field.
tempDir

string

No comment on field.
cacheExpiryDuration

time.Duration

No comment on field.
debugFunc

DebugFunc

No comment on field.
promptFunc

PromptFunc

No comment on field.
promptMutex

sync.Mutex

No comment on field.

SnippetOption, Snippet

This type doesn't have documentation.

Field name Field type Comment
type

any

No comment on field.
linesRaw

[]string

No comment on field.
linesHighlighted

[]string

No comment on field.
start

int

No comment on field.
end

int

No comment on field.
line

int

No comment on field.
column

int

No comment on field.
padding

int

No comment on field.
noIndicators

bool

No comment on field.

cacheExpiryDurationOption

This type doesn't have documentation.

Field name Field type Comment
duration

time.Duration

No comment on field.

columnOption

This type doesn't have documentation.

Field name Field type Comment
column

int

No comment on field.

debugFuncOption

This type doesn't have documentation.

Field name Field type Comment
debugFunc

DebugFunc

No comment on field.

downloadOption

This type doesn't have documentation.

Field name Field type Comment
download

bool

No comment on field.

insecureOption

This type doesn't have documentation.

Field name Field type Comment
insecure

bool

No comment on field.

lineOption

This type doesn't have documentation.

Field name Field type Comment
line

int

No comment on field.

noIndicatorsOption

This type doesn't have documentation.

offlineOption

This type doesn't have documentation.

Field name Field type Comment
offline

bool

No comment on field.

paddingOption

This type doesn't have documentation.

Field name Field type Comment
padding

int

No comment on field.

promptFuncOption

This type doesn't have documentation.

Field name Field type Comment
promptFunc

PromptFunc

No comment on field.

tempDirOption

This type doesn't have documentation.

Field name Field type Comment
tempDir

string

No comment on field.

Functions

func Dotenv

Uses: ast.NewVars, ast.Var, filepathext.SmartJoin, fmt.Errorf, godotenv.Read, os.IsNotExist, os.Stat, templater.Cache, templater.Replace.

func NewBaseNode

func NewCacheNode

Uses: filepath.Join.

func NewFileNode

Uses: fsext.Search.

func NewGitNode

Uses: errors.TaskfileNotSecureError, giturls.Parse.

func NewHTTPNode

Uses: errors.TaskfileNotSecureError, url.Parse.

func NewNode

Uses: errors.New, experiments.RemoteTaskfiles.

func NewReader

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

Uses: ast.NewTaskfileGraph, os.TempDir, sync.Mutex.

func NewRootNode

Uses: fsext.DefaultDir.

func NewSnippet

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.

Uses: bytes.Buffer, quick.Highlight, strings.Split.

func NewStdinNode

func RemoteExists

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.

Uses: errors.TaskfileFetchFailedError, errors.TaskfileNotFoundError, fmt.Errorf, http.DefaultClient, http.NewRequestWithContext, http.StatusOK, slices.ContainsFunc, strings.Contains.

func WithCacheExpiryDuration

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

func WithChecksum

func WithColumn

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

func WithDebugFunc

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

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

func WithInsecure

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

func WithLine

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

func WithNoIndicators

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

func WithOffline

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 WithPadding

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

func WithParent

func WithPromptFunc

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

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

func (*CacheNode) ChecksumPrompt

func (*CacheNode) CreateCacheDir

Uses: os.MkdirAll.

func (*CacheNode) Location

func (*CacheNode) Read

Uses: os.ReadFile.

func (*CacheNode) ReadChecksum

Uses: os.ReadFile.

func (*CacheNode) ReadTimestamp

Uses: os.ReadFile, time.Parse, time.RFC3339, time.Time.

func (*CacheNode) Write

Uses: os.WriteFile.

func (*CacheNode) WriteChecksum

Uses: os.WriteFile.

func (*CacheNode) WriteTimestamp

Uses: os.WriteFile, time.RFC3339.

func (*FileNode) Location

func (*FileNode) Read

Uses: io.ReadAll, os.Open.

func (*FileNode) ResolveDir

Uses: execext.ExpandLiteral, filepath.Dir, filepathext.IsAbs, filepathext.SmartJoin.

func (*FileNode) ResolveEntrypoint

Uses: execext.ExpandLiteral, filepath.Dir, filepathext.IsAbs, filepathext.SmartJoin, strings.Contains, strings.HasPrefix.

func (*GitNode) CacheKey

Uses: filepath.Base, filepath.Dir, fmt.Sprintf, strings.TrimRight.

func (*GitNode) Location

func (*GitNode) Read

Uses: context.Background.

func (*GitNode) ReadContext

Uses: io.ReadAll, memfs.New, memory.NewStorage, plumbing.ReferenceName.

func (*GitNode) Remote

func (*GitNode) ResolveDir

Uses: execext.ExpandLiteral, filepath.Dir, filepathext.IsAbs, filepathext.SmartJoin.

func (*GitNode) ResolveEntrypoint

Uses: filepath.Join, filepath.Split, fmt.Sprintf.

func (*HTTPNode) CacheKey

Uses: filepath.Base, filepath.Split, fmt.Sprintf, strings.TrimRight.

func (*HTTPNode) Location

func (*HTTPNode) Read

Uses: context.Background.

func (*HTTPNode) ReadContext

Uses: errors.TaskfileFetchFailedError, http.DefaultClient, http.NewRequest, http.StatusOK, io.ReadAll.

func (*HTTPNode) ResolveDir

Uses: execext.ExpandLiteral, filepathext.IsAbs, filepathext.SmartJoin.

func (*HTTPNode) ResolveEntrypoint

Uses: url.Parse.

func (*Reader) Options

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

func (*Reader) Read

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.

func (*Snippet) Options

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

func (*Snippet) String

Uses: bytes.Buffer, color.RedString, fmt.Fprintf, fmt.Fprintln, fmt.Sprintf, strings.Repeat.

func (*StdinNode) Location

func (*StdinNode) Read

Uses: bufio.NewScanner, fmt.Appendln, os.Stdin.

func (*StdinNode) Remote

func (*StdinNode) ResolveDir

Uses: execext.ExpandLiteral, filepathext.IsAbs, filepathext.SmartJoin.

func (*StdinNode) ResolveEntrypoint

Uses: execext.ExpandLiteral, filepathext.IsAbs, filepathext.SmartJoin, strings.Contains.

func (*baseNode) Checksum

func (*baseNode) Dir

func (*baseNode) Parent

func (*baseNode) Verify

func (*cacheExpiryDurationOption) ApplyToReader

func (*columnOption) ApplyToSnippet

func (*debugFuncOption) ApplyToReader

func (*downloadOption) ApplyToReader

func (*insecureOption) ApplyToReader

func (*lineOption) ApplyToSnippet

func (*noIndicatorsOption) ApplyToSnippet

func (*offlineOption) ApplyToReader

func (*paddingOption) ApplyToSnippet

func (*promptFuncOption) ApplyToReader

func (*tempDirOption) ApplyToReader

Private functions

func checksum

References: fmt.Sprintf, sha256.New.

func digits

func getScheme

References: giturls.Parse, strings.HasSuffix, strings.Index, strings.Split.

func init

References: styles.Register.

func splitURLOnDoubleSlash

References: strings.Split.

func checksumPath

func filePath

References: filepath.Join, fmt.Sprintf.

func timestampPath

func debugf

References: fmt.Sprintf.

func include

References: ast.Include, ast.TaskfileVertex, env.GetEnviron, errgroup.Group, errors.Is, errors.TaskfileCycleError, graph.EdgeData, graph.EdgeWeight, graph.ErrEdgeCreatesCycle, graph.ErrEdgeNotFound, graph.ErrVertexAlreadyExists, templater.Cache, templater.Replace.

func promptf

References: fmt.Sprintf.

func readNode

References: ast.Task, ast.Taskfile, errors.As, errors.TaskfileDecodeError, errors.TaskfileInvalidError, errors.TaskfileVersionCheckError, filepathext.TryAbsToRel.

func readNodeContent

References: errors.TaskfileDoesNotMatchChecksum.

func readRemoteNodeContent

References: errors.Is, errors.TaskfileCacheNotFoundError, errors.TaskfileDoesNotMatchChecksum, errors.TaskfileNotTrustedError, os.ErrNotExist, time.Now, time.RFC3339.


Tests

Files: 4. Third party imports: 2. Imports from organisation: 0. Tests: 9. Benchmarks: 0.

Constants

Test functions

TestGitNode_CacheKey

References: assert.Equal, require.NoError.

TestGitNode_https

References: assert.Equal, assert.NoError.

TestGitNode_httpsWithDir

References: assert.Equal, assert.NoError.

TestGitNode_ssh

References: assert.Equal, assert.NoError.

TestGitNode_sshWithDir

References: assert.Equal, assert.NoError.

TestHTTPNode_CacheKey

References: assert.Equal, require.NoError.

TestNewSnippet

References: require.Equal, testing.T.

TestScheme

References: assert.Equal, assert.NoError.

TestSnippetString

References: require.Equal, strings.Contains, testing.T.