todotxt

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2024 License: GPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

The purpose of this package is to provide an API that strictly complies with the todotxt spec. In particular this means that any non-standard behavior (including recurring tasks) does not belong here, but in the extensions package

Index

Constants

This section is empty.

Variables

View Source
var DefaultDecoder = Decoder{}
View Source
var DefaultEncoder = Encoder{}
View Source
var DefaultJsonEncoder = JsonEncoder{}
View Source
var ErrAbort = errors.New("operation aborted by hook")
View Source
var ErrCompleteBeforeCreation = errors.New("completion date can not be before creation date")
View Source
var ErrCompletionDateWhileUndone = errors.New("completion date can not be set on undone task")
View Source
var ErrCreationDateUnset = errors.New("completion date can not be set while creation date is not")
View Source
var ErrNoPrioWhenDone = errors.New("done tasks must not have a priority")
View Source
var NoNoteIdsError = errors.New("could not find a new id in a reasonable amount of time. Try running \"quest notes clean\" or consider increasting id length")

Functions

func MatcherForTag

func MatcherForTag(key string) *regexp.Regexp

MatcherForTag returns a regular expression that matches a tag with the supplied key. To access the value consult submatch 1

Any leading/trailing whitespace in key will be removed before constructing the matcher Any remaining whitespace will be replaced with +

Types

type BuildFunc

type BuildFunc func(*Item) *Item

func CopyOf

func CopyOf(item *Item) BuildFunc

func WithCompletionDate

func WithCompletionDate(date time.Time) BuildFunc

func WithCreationDate

func WithCreationDate(date time.Time) BuildFunc

func WithDescription

func WithDescription(desc string) BuildFunc

func WithDone

func WithDone(done bool) BuildFunc

func WithMeta

func WithMeta(done bool, prio Priority, completionDate time.Time, creationDate time.Time) BuildFunc

func WithNowFunc

func WithNowFunc(now func() time.Time) BuildFunc

func WithPriority

func WithPriority(prio Priority) BuildFunc

func WithoutCompletionDate

func WithoutCompletionDate() BuildFunc

func WithoutCreationDate

func WithoutCreationDate() BuildFunc

type Context

type Context string

func (Context) Matcher

func (c Context) Matcher() *regexp.Regexp

Matcher returns a regular expression matching this specific context. The Match will contain a leading and trailing whitespace, the context description without whitespace will be matched by submatch 1

func (Context) String

func (c Context) String() string

type Decoder

type Decoder struct {
}

func (*Decoder) Decode

func (d *Decoder) Decode(r io.Reader) ([]*Item, error)

type Encoder

type Encoder struct {
}

func (Encoder) Encode

func (f Encoder) Encode(w io.Writer, tasks []*Item) error

type Event

type Event interface {
	Dispatch(*List, Hook) error
}

type Hook

type Hook interface {
	OnMod(list *List, event ModEvent) error
	OnValidate(list *List, event ValidationEvent) error
}

type HookFunc

type HookFunc func(*List, ModEvent) error

func (HookFunc) OnMod

func (h HookFunc) OnMod(list *List, event ModEvent) error

func (HookFunc) OnValidate

func (h HookFunc) OnValidate(*List, ValidationEvent) error

type Item

type Item struct {
	// contains filtered or unexported fields
}

func BuildItem

func BuildItem(modifier ...BuildFunc) (*Item, error)

func MustBuildItem

func MustBuildItem(m ...BuildFunc) *Item

func (*Item) Apply

func (i *Item) Apply(item *Item) error

func (*Item) CleanDescription

func (i *Item) CleanDescription(projects []Project, contexts []Context, tags []string) string

func (*Item) Complete

func (i *Item) Complete() error

func (*Item) CompletionDate

func (i *Item) CompletionDate() *time.Time

func (*Item) Contexts

func (i *Item) Contexts() []Context

func (*Item) CreationDate

func (i *Item) CreationDate() *time.Time

func (*Item) Description

func (i *Item) Description() string

func (*Item) Done

func (i *Item) Done() bool

func (*Item) EditDescription

func (i *Item) EditDescription(desc string) error

func (*Item) Equals

func (i *Item) Equals(item *Item) bool

func (*Item) MarkUndone

func (i *Item) MarkUndone() error

func (*Item) PrioritizeAs

func (i *Item) PrioritizeAs(prio Priority) error

func (*Item) Priority

func (i *Item) Priority() Priority

func (*Item) Projects

func (i *Item) Projects() []Project

func (*Item) SetCreation

func (i *Item) SetCreation(creation time.Time) error

func (*Item) SetTag

func (i *Item) SetTag(key, value string) error

func (*Item) String

func (i *Item) String() string

func (*Item) Tags

func (i *Item) Tags() Tags

type JsonEncoder

type JsonEncoder struct {
}

func (JsonEncoder) Encode

func (f JsonEncoder) Encode(w io.Writer, list *List, tasks []*Item) error

type List

type List struct {
	// contains filtered or unexported fields
}

func ListOf

func ListOf(items ...*Item) *List

func (*List) Add

func (l *List) Add(items ...*Item) (err error)

func (*List) AddHook

func (l *List) AddHook(hook Hook)

func (*List) AllContexts

func (l *List) AllContexts() []Context

func (*List) AllProjects

func (l *List) AllProjects() []Project

func (*List) AllTags

func (l *List) AllTags() []string

func (*List) GetLine

func (l *List) GetLine(line int) *Item

func (*List) Len

func (l *List) Len() int

func (*List) LineOf

func (l *List) LineOf(i *Item) int

func (*List) Remove

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

func (*List) Reset

func (l *List) Reset()

func (*List) Secret

func (l *List) Secret(secretChange func() error) error

func (*List) Snapshot

func (l *List) Snapshot()

func (*List) Tasks

func (l *List) Tasks() []*Item

Tasks returns all non deleted items like they are ordered on disk.

type ModEvent

type ModEvent struct {
	Previous *Item
	Current  *Item
}

ModEvent is an event that is issued whenever a modification to the list happens. In case a task was added previous will be nil and current non-nil In case an existing task was modified both will be non-nil In case a task was removed previous will be non-nil and current will be nil It is legal to modify Current from within a hook. e.g. to undo a change do `*Current = *Previous`

func (ModEvent) Dispatch

func (m ModEvent) Dispatch(list *List, h Hook) error

func (ModEvent) IsCompleteEvent

func (m ModEvent) IsCompleteEvent() bool

type NotesRepo added in v0.4.0

type NotesRepo struct {
	IdLength int
	// contains filtered or unexported fields
}

func NewNotesRepo added in v0.4.0

func NewNotesRepo(notesTag string, notesDir string) *NotesRepo

func (*NotesRepo) Clean added in v0.4.0

func (n *NotesRepo) Clean(lists ...*List) error

func (*NotesRepo) Get added in v0.4.0

func (n *NotesRepo) Get(item *Item) (string, error)

type OLockError

type OLockError struct {
	BackupPath string
}

func (OLockError) Error

func (o OLockError) Error() string

type ParseError

type ParseError struct {
	// contains filtered or unexported fields
}

func (ParseError) Error

func (p ParseError) Error() string

type Priority

type Priority byte
const (
	PrioNone Priority = iota
	PrioZ
	PrioY
	PrioX
	PrioW
	PrioV
	PrioU
	PrioT
	PrioS
	PrioR
	PrioQ
	PrioP
	PrioO
	PrioN
	PrioM
	PrioL
	PrioK
	PrioJ
	PrioI
	PrioH
	PrioG
	PrioF
	PrioE
	PrioD
	PrioC
	PrioB
	PrioA
)

Reverse order so that wen can compare using <=

func PriorityFromString

func PriorityFromString(prio string) (Priority, error)

func (Priority) String

func (p Priority) String() string

type Project

type Project string

func (Project) Matcher

func (p Project) Matcher() *regexp.Regexp

Matcher returns a regular expression matching this specific project. The Match will contain a leading a trailing whitespace, the project description without whitespace will be matched by submatch 1

func (Project) String

func (p Project) String() string

type ReadError

type ReadError struct {
	BaseError  error
	Line       string
	LineNumber int
}

func (ReadError) Error

func (r ReadError) Error() string

func (ReadError) Unwrap

func (r ReadError) Unwrap() error

type ReadFunc

type ReadFunc func() (*List, error)

type Repo

type Repo struct {
	Encoder      *Encoder
	Decoder      *Decoder
	DefaultHooks []Hook
	Keep         int
	// contains filtered or unexported fields
}

func NewRepo

func NewRepo(dest string) *Repo

func (*Repo) Close

func (t *Repo) Close() error

func (*Repo) Read

func (t *Repo) Read() (*List, error)

func (*Repo) Save

func (t *Repo) Save(l *List) error

func (*Repo) Watch

func (t *Repo) Watch() (<-chan ReadFunc, func(), error)

Watch watches watches for file changes. The second return argument can be used to unregister the watcher. However, that function must not be called from the same go routine that listens on the returned channel. When in doubt you can close it asynchronosuly `go remove()`

type Tags

type Tags map[string][]string

func (Tags) Keys

func (t Tags) Keys() []string

type ValidationError

type ValidationError struct {
	Base          error
	OffendingItem *Item
	Line          int
}

func (ValidationError) Error

func (v ValidationError) Error() string

func (ValidationError) Unwrap

func (v ValidationError) Unwrap() error

type ValidationEvent

type ValidationEvent struct {
	Item *Item
}

func (ValidationEvent) Dispatch

func (v ValidationEvent) Dispatch(list *List, h Hook) error

Jump to

Keyboard shortcuts

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