Documentation
¶
Index ¶
- Variables
- func ExtractDataFromLoadEvent[T any](event LoadEvent) T
- func FormatFiles(files []string, options *FormatOptions) error
- func GetRelativePath(cwd, path string) string
- func LoadFiles(ctx context.Context, p *Project) ([]string, error)
- func SortByProximity(tasks []Task, cwd string)
- type Filter
- type FormatOptions
- type FuncOutput
- type LoadEvent
- type LoadEventErrorData
- type LoadEventFinishedParsingDocumentData
- type LoadEventFinishedWalkData
- type LoadEventFoundDirData
- type LoadEventFoundFileData
- type LoadEventFoundTaskData
- type LoadEventStartedParsingDocumentData
- type LoadEventStartedWalkData
- type LoadEventType
- type LoadOptions
- type Matcher
- type Project
- func (p *Project) EnvDirEnvEnabled() bool
- func (p *Project) EnvFilesReadOrder() []string
- func (p *Project) Load(ctx context.Context, eventc chan<- LoadEvent, onlyFiles bool)
- func (p *Project) LoadEnv() ([]string, error)
- func (p *Project) LoadEnvAsMap() (map[string]string, error)
- func (p *Project) LoadEnvWithSource() (envWithSource map[string]map[string]string, err error)
- func (p *Project) LoadRawFile(file string) ([]byte, error)
- func (p *Project) LoadWithOptions(ctx context.Context, eventc chan<- LoadEvent, options LoadOptions)
- func (p *Project) Root() string
- type ProjectOption
- func WithEnvDirEnv(value bool) ProjectOption
- func WithEnvFilesReadOrder(order []string) ProjectOption
- func WithFindRepoUpward() ProjectOption
- func WithIgnoreFilePatterns(patterns ...string) ProjectOption
- func WithLogger(logger *zap.Logger) ProjectOption
- func WithRespectGitignore(value bool) ProjectOption
- type Task
- func FilterTasksByExactTaskName(tasks []Task, name string) (result []Task, err error)
- func FilterTasksByFilename(tasks []Task, expr string) (result []Task, err error)
- func FilterTasksByFn(tasks []Task, fns ...Filter) (result []Task, err error)
- func FilterTasksByID(tasks []Task, expr string) (result []Task, err error)
- func LoadTasks(ctx context.Context, p *Project) ([]Task, error)
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultProjectOptions = [...]ProjectOption{ WithFindRepoUpward(), WithRespectGitignore(true), WithEnvFilesReadOrder([]string{".env"}), WithIgnoreFilePatterns("node_modules", ".venv", "vendor"), }
View Source
var ErrReturnEarly = errors.New("return early")
Functions ¶
func FormatFiles ¶
func FormatFiles(files []string, options *FormatOptions) error
func GetRelativePath ¶
func SortByProximity ¶
SortByProximity sorts tasks by promximity to the cwd
Types ¶
type FormatOptions ¶
type FormatOptions struct {
IdentityResolver *identity.IdentityResolver
FormatJSON bool
Write bool
Outputter FuncOutput
Reset bool
}
type FuncOutput ¶
type LoadEvent ¶
type LoadEvent struct {
Type LoadEventType
Data any
}
type LoadEventErrorData ¶
type LoadEventErrorData struct {
Err error
}
type LoadEventFinishedParsingDocumentData ¶
type LoadEventFinishedParsingDocumentData struct {
Path string
}
type LoadEventFinishedWalkData ¶
type LoadEventFinishedWalkData struct{}
type LoadEventFoundDirData ¶
type LoadEventFoundDirData struct {
Path string
}
type LoadEventFoundFileData ¶
type LoadEventFoundFileData struct {
Path string
}
type LoadEventFoundTaskData ¶
type LoadEventFoundTaskData struct {
Task Task
}
type LoadEventStartedParsingDocumentData ¶
type LoadEventStartedParsingDocumentData struct {
Path string
}
type LoadEventStartedWalkData ¶
type LoadEventStartedWalkData struct{}
type LoadEventType ¶
type LoadEventType uint8
const ( LoadEventStartedWalk LoadEventType = iota + 1 LoadEventFoundDir LoadEventFoundFile LoadEventFinishedWalk LoadEventStartedParsingDocument LoadEventFinishedParsingDocument LoadEventFoundTask LoadEventError )
type LoadOptions ¶
type LoadOptions struct {
OnlyFiles bool
}
type Matcher ¶
func CompileRegex ¶
type Project ¶
type Project struct {
// contains filtered or unexported fields
}
func NewDirProject ¶
func NewDirProject( dir string, opts ...ProjectOption, ) (*Project, error)
func NewFileProject ¶
func NewFileProject( path string, opts ...ProjectOption, ) (*Project, error)
func (*Project) EnvDirEnvEnabled ¶
func (*Project) EnvFilesReadOrder ¶
func (*Project) LoadEnvWithSource ¶
func (*Project) LoadWithOptions ¶
func (p *Project) LoadWithOptions( ctx context.Context, eventc chan<- LoadEvent, options LoadOptions, )
type ProjectOption ¶
type ProjectOption func(*Project)
func WithEnvDirEnv ¶
func WithEnvDirEnv(value bool) ProjectOption
func WithEnvFilesReadOrder ¶
func WithEnvFilesReadOrder(order []string) ProjectOption
func WithFindRepoUpward ¶
func WithFindRepoUpward() ProjectOption
func WithIgnoreFilePatterns ¶
func WithIgnoreFilePatterns(patterns ...string) ProjectOption
func WithLogger ¶
func WithLogger(logger *zap.Logger) ProjectOption
func WithRespectGitignore ¶
func WithRespectGitignore(value bool) ProjectOption
type Task ¶
type Task struct {
CodeBlock *document.CodeBlock `json:"code_block"`
DocumentPath string `json:"document_path"`
RelDocumentPath string `json:"rel_document_path"`
}
Task is struct representing a document.CodeBlock within the context of a project. Instance of document.Document can be retrieved from Task's code block. Task contains absolute and relative path to the document.
func FilterTasksByFilename ¶
func (Task) BlockInterpreter ¶ added in v3.13.2
BlockInterpreter returns the interpreter specified in the code block attributes, or an empty string if not set.
func (Task) CustomShell ¶ added in v3.13.2
CustomShell returns the shell to use for this task, prioritizing frontmatter shell, then block interpreter, then the provided baseShell.
func (Task) FrontmatterShell ¶ added in v3.13.2
FrontmatterShell returns the shell specified in the document frontmatter, or an error if the frontmatter is invalid or missing.
Click to show internal directories.
Click to hide internal directories.