task

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 27, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package task implements the task contract of §6.1: one markdown file per task under .devclean/tasks/, with a frontmatter block in the same yaml subset as config.yml and a free notes body.

Index

Constants

View Source
const (
	DefaultLimiteIntentos = 3
	DefaultLimiteLineas   = 200
)

Defaults for the optional contract fields (§6.1).

View Source
const Version = 1

Version is the contract version this binary understands (adenda A.1). A file declaring a higher one is read tolerantly and reported.

Variables

This section is empty.

Functions

func NextID

func NextID(dir string) (string, error)

NextID scans dir and returns the first free correlative ID.

func Path

func Path(dir, id string) string

Path returns the file path of a task inside a tasks directory.

func Remove

func Remove(dir, id string) error

Remove deletes the task file.

func Save

func Save(dir string, t Task) error

Save writes the task to dir/<id>.md.

func ValidID

func ValidID(id string) bool

ValidID reports whether id has the contract format.

Types

type Task

type Task struct {
	Version        int      `json:"version"`
	ID             string   `json:"id"`
	Titulo         string   `json:"titulo"`
	Porque         string   `json:"porque"`
	ListoCuando    string   `json:"listo_cuando"`
	TocarSolo      []string `json:"tocar_solo"`
	NoTocar        []string `json:"no_tocar"`
	DependeDe      []string `json:"depende_de,omitempty"`
	LimiteIntentos int      `json:"limite_intentos"`
	LimiteLineas   int      `json:"limite_lineas"`
	Riesgos        string   `json:"riesgos"`
	Peso           string   `json:"peso,omitempty"` // liviana | media | pesada ("" = estrategia global)

	// Notas is the free body after the frontmatter.
	Notas string `json:"notas,omitempty"`

	// Aviso carries the warning of a contract written by a newer
	// devclean: it parsed, but fields were skipped.
	Aviso string `json:"aviso,omitempty"`
}

Task is the task contract. ListoCuando is the only mandatory field beyond id and titulo; the rest carry defaults.

func List

func List(dir string) ([]Task, error)

List returns every task in dir, sorted by ID. A malformed file fails the whole listing: the tasks directory must stay clean.

func Load

func Load(dir, id string) (Task, error)

Load reads the task with the given id from dir.

func Parse

func Parse(data []byte) (Task, error)

Parse reads a task file. Unknown keys and malformed values are rejected: the contract is the guardrail, so it is strict.

func (Task) Marshal

func (t Task) Marshal() []byte

Marshal renders the task file.

func (Task) Validate

func (t Task) Validate() []error

Validate checks the contract rules and returns every problem found. An empty slice means the contract is valid.

Jump to

Keyboard shortcuts

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