taskfile

package
v0.4.7 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package taskfile reads and updates task markdown files on disk.

It modifies YAML frontmatter fields (status, tags, dependencies, PRs) and body content while preserving the rest of the file unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ComputeNewTags

func ComputeNewTags(current, addTags, removeTags []string) []string

ComputeNewTags computes the resulting tag list after additions and removals.

func FindFrontmatterBounds

func FindFrontmatterBounds(lines []string) (int, int)

FindFrontmatterBounds returns the line indices of the opening and closing "---" delimiters.

func FormatInlineList

func FormatInlineList(fieldName string, values []string) string

FormatInlineList formats a named list field as inline YAML: field: ["a", "b"]

func FormatInlineTags

func FormatInlineTags(tags []string) string

FormatInlineTags formats tags as inline YAML: tags: ["a", "b"]

func ReplaceID

func ReplaceID(filePath, newID string) error

ReplaceID rewrites the id field in a task file's frontmatter.

func ReplaceReference

func ReplaceReference(filePath, oldID, newID string) error

ReplaceReference replaces occurrences of oldID with newID in dependency and parent fields within a task file's frontmatter.

func RewriteTitleHeading added in v0.4.1

func RewriteTitleHeading(filePath, oldTitle, newTitle string) (bool, error)

RewriteTitleHeading replaces the body's level-1 heading with newTitle, but only when the existing heading matches oldTitle. It reports whether the heading was rewritten.

A heading that has diverged from the frontmatter title is a deliberate choice by the author, so it is left alone rather than silently overwritten.

func UpdateTaskFile

func UpdateTaskFile(filePath string, req UpdateRequest) error

UpdateTaskFile reads a task markdown file, applies the requested changes, and writes it back.

func ValidateUpdateRequest

func ValidateUpdateRequest(req UpdateRequest, efforts effort.Scale) []string

ValidateUpdateRequest checks enum fields and returns a list of error strings.

efforts supplies the project's effort vocabulary; pass effort.Scale{} for the default small, medium, large.

Types

type Heading added in v0.4.1

type Heading struct {
	Found bool   // whether the body has a level-1 heading at all
	Line  int    // 0-based line index of the heading, or -1 when not found
	Text  string // heading text with the leading "# " stripped
}

Heading describes the level-1 markdown heading in a task file's body — the line that conventionally mirrors the frontmatter title.

func FindTitleHeading added in v0.4.1

func FindTitleHeading(filePath string) (Heading, error)

FindTitleHeading returns the first level-1 heading in a task file's body.

Headings inside fenced code blocks are skipped: a `# comment` line in a shell snippet is not a title.

type UpdateRequest

type UpdateRequest struct {
	Title        *string
	Status       *string
	Priority     *string
	Effort       *string
	Type         *string
	Owner        *string
	Parent       *string
	Tags         *[]string // replace tags entirely
	AddTags      []string  // add to existing tags
	RemTags      []string  // remove from existing tags
	AddPRs       []string  // add PR URLs
	RemPRs       []string  // remove PR URLs
	AddTouches   []string  // add scope identifiers to touches
	RemTouches   []string  // remove scope identifiers from touches
	Phase        *string
	Completed    *string   // completed date (YYYY-MM-DD)
	CancelledAt  *string   // cancelled date (YYYY-MM-DD)
	Dependencies *[]string // replace dependencies entirely
	RemoveFields []string  // field keys to remove entirely from frontmatter
	Body         *string
}

UpdateRequest describes which fields to update. Nil pointer means "no change".

Jump to

Keyboard shortcuts

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