todo

package
v0.0.0-beta Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package todo manages a list of tasks with status tracking.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidIndex = errors.New("invalid todo index")

ErrInvalidIndex is returned when an operation targets an out-of-range index.

Functions

This section is empty.

Types

type List

type List struct {
	Summary string `json:"summary,omitempty"`
	Items   []Todo `json:"items"`
}

List holds an ordered collection of todos and an optional summary.

func New

func New() *List

New creates an empty List.

func Parse

func Parse(text string) (*List, error)

Parse parses a text representation of a todo list (as produced by String) back into a List. Unrecognized lines are silently ignored. Returns an error only if a matched todo line contains an invalid status.

func (*List) Add

func (l *List) Add(todo Todo)

Add appends a new todo to the list.

func (*List) AllCompleted

func (l *List) AllCompleted() bool

AllCompleted reports whether all items are completed, or the list is empty.

func (*List) ByStatus

func (l *List) ByStatus(status Status) []int

ByStatus returns the indices of all todos matching the given status.

func (*List) Complete

func (l *List) Complete(index int) error

Complete marks the todo at the given index as completed.

func (*List) Counts

func (l *List) Counts() (pending, inProgress, completed int)

Counts returns the number of pending, in-progress, and completed items.

func (*List) FindInProgress

func (l *List) FindInProgress() []int

FindInProgress returns the indices of all in-progress todos.

func (*List) FindPending

func (l *List) FindPending() []int

FindPending returns the indices of all pending todos.

func (*List) Get

func (l *List) Get() []Todo

Get returns the current todo list.

func (*List) IsEmpty

func (l *List) IsEmpty() bool

IsEmpty reports whether the list has no items and no summary.

func (*List) Len

func (l *List) Len() int

Len returns the total number of items in the list.

func (*List) MarkStatus

func (l *List) MarkStatus(index int, status Status) error

MarkStatus updates the status of the todo at the given index.

func (*List) Remove

func (l *List) Remove(index int) error

Remove removes the todo at the given index.

func (*List) Replace

func (l *List) Replace(todos []Todo)

Replace replaces the entire todo list with the provided todos.

func (*List) SetSummary

func (l *List) SetSummary(summary string)

SetSummary updates the executive summary.

func (*List) String

func (l *List) String() string

String formats the todo list for display.

type Status

type Status string

Status represents the current state of a todo item.

const (
	Pending    Status = "pending"
	InProgress Status = "in_progress"
	Completed  Status = "completed"
)

type Todo

type Todo struct {
	Content string `json:"content"`
	Status  Status `json:"status"`
}

Todo represents a single task with its content and current state.

Jump to

Keyboard shortcuts

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