gotodo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ListPending = iota
	ListAll
	ListDone
)

ListPending is all active todos ListAll is all todos, active and complete ListDone is all completed todos

View Source
const TimeFormat = "2006-01-02"

TimeFormat is the YYYY-MM-DD format used by todo.txt

Variables

View Source
var InvalidTime = NullTime{Valid: false}

InvalidTime is a NullTime with Valid set to false and Time set to time.Time{}

Functions

This section is empty.

Types

type Attributes

type Attributes map[string]string

Attributes is a key/value store for custom Todo metadata

type BoltStorage

type BoltStorage struct{}

BoltStorage implements Storage, saving items to a file in the filesystem

func (*BoltStorage) Create

func (me *BoltStorage) Create(todo *Todo) error

Create inserts a new *Todo

func (*BoltStorage) Delete

func (me *BoltStorage) Delete(todoID int) error

Delete removes the *Todo identified by todoID

func (*BoltStorage) Get

func (me *BoltStorage) Get(todoID int) (*Todo, error)

Get retrieves the *Todo identified by todoID

func (*BoltStorage) List

func (me *BoltStorage) List() (TodoList, error)

List reads all Todos

func (*BoltStorage) Update

func (me *BoltStorage) Update(todoID int, todo *Todo) error

Update modifies the *Todo identified by todoID

type ByCreatedDate

type ByCreatedDate TodoList

ByCreatedDate provides sorting by Todo.CreationDate

func (ByCreatedDate) Len

func (s ByCreatedDate) Len() int

Len returns length of the slice

func (ByCreatedDate) Less

func (s ByCreatedDate) Less(i, j int) bool

Less compares two elements by CreationDate

func (ByCreatedDate) Swap

func (s ByCreatedDate) Swap(i, j int)

Swap inverts positions of two elements

type ByDueDate

type ByDueDate TodoList

ByDueDate provides sorting by Todo.DueDate

func (ByDueDate) Len

func (s ByDueDate) Len() int

Len returns length of the slice

func (ByDueDate) Less

func (s ByDueDate) Less(i, j int) bool

Less compares two elements by DueDate

func (ByDueDate) Swap

func (s ByDueDate) Swap(i, j int)

Swap inverts positions of two elements

type ByPriority

type ByPriority TodoList

ByPriority provides sorting by Todo.Priority

func (ByPriority) Len

func (s ByPriority) Len() int

Len returns length of the slice

func (ByPriority) Less

func (s ByPriority) Less(i, j int) bool

Less compares two elements by Priority

func (ByPriority) Swap

func (s ByPriority) Swap(i, j int)

Swap inverts positions of two elements

type NullTime

type NullTime struct {
	Time  time.Time
	Valid bool
}

NullTime combines time.Time with a flag to indicate its validity

func NewNullTime

func NewNullTime(timeStr string) NullTime

NewNullTime takes a timestamp and returns a NullTime

func ValidTime

func ValidTime(time time.Time) NullTime

ValidTime returns a NullTime with Valid set to true and Time set to given time

func (NullTime) Display

func (me NullTime) Display() string

Display formats a NullTime in YYYY-MM-DD format

type Storage

type Storage interface {
	Create(todo *Todo) error
	List() (TodoList, error)
	Get(todoID int) (*Todo, error)
	Update(todoID int, todo *Todo) error
	Delete(todoID int) error
}

Storage provides an interface for various todo storage mechanisms (in-memory, filesystem)

type Tags

type Tags map[string]void

Tags is a key/value store for custom Todo metadata

type Todo

type Todo struct {
	TodoID           int
	Complete         bool
	Priority         int
	CompletionDate   NullTime
	CreationDate     NullTime
	DueDate          NullTime
	Description      string
	Projects         Tags
	Contexts         Tags
	CustomAttributes Attributes
}

Todo contains information about a specific Todo

func FromString

func FromString(todoStr string) *Todo

FromString translates a todotxt string into a *Todo

func (*Todo) String

func (me *Todo) String() string

String converts a Todo into a todotxt-formatted string

type TodoList

type TodoList []*Todo

TodoList is list of Todos

type TodoListFilter

type TodoListFilter struct {
	Status    int
	Project   string
	Context   string
	Attribute string
}

TodoListFilter provides filtering criteria for a TodoList

type TodoManager

type TodoManager struct {
	Storage Storage
}

TodoManager controls a TodoList

func (*TodoManager) Add

func (me *TodoManager) Add(todoStr string) (int, error)

Add takes a todotxt string and adds it to the list of todos

func (*TodoManager) AddAttribute

func (me *TodoManager) AddAttribute(todoID int, attr string) error

AddAttribute adds a context tag to a todo

func (*TodoManager) AddContext

func (me *TodoManager) AddContext(todoID int, context string) error

AddContext adds a context tag to a todo

func (*TodoManager) AddProject

func (me *TodoManager) AddProject(todoID int, project string) error

AddProject adds a project tag to a todo

func (*TodoManager) Append

func (me *TodoManager) Append(todoID int, appendStr string) error

Append adds a string message to the end of a todo description

func (*TodoManager) Complete

func (me *TodoManager) Complete(todoID int) error

Complete changes the completion status of a Todo to done and adds CompletionDate

func (*TodoManager) Delete

func (me *TodoManager) Delete(todoID int) error

Delete drops the item specified by todoId from a TodoManager

func (*TodoManager) Deprioritize

func (me *TodoManager) Deprioritize(todoID int) error

Deprioritize changes the priority of a Todo identified by todoID

func (*TodoManager) List

func (me *TodoManager) List(listFilter TodoListFilter) (TodoList, error)

List returns a slice of Todos as determined by TodoListFilter criteria

func (*TodoManager) ListAttributes

func (me *TodoManager) ListAttributes() ([]string, error)

ListAttributes returns a list of unique attribute keys

func (*TodoManager) ListContexts

func (me *TodoManager) ListContexts() ([]string, error)

ListContexts returns a list of unique contexts

func (*TodoManager) ListProjects

func (me *TodoManager) ListProjects() ([]string, error)

ListProjects returns a list of unique projects

func (*TodoManager) Prepend

func (me *TodoManager) Prepend(todoID int, prependStr string) error

Prepend adds a string message to the front of a todo description

func (*TodoManager) Prioritize

func (me *TodoManager) Prioritize(todoID int, priorityString string) error

Prioritize changes the priority of a Todo identified by todoID

func (*TodoManager) Resume

func (me *TodoManager) Resume(todoID int) error

Resume changes the completion status of a todo and invalidates CompletionDate

func (*TodoManager) Update

func (me *TodoManager) Update(todoID int, todoStr string) error

Update takes the ID number of an existing Todo and a parseable todo string and replaces all contents of the existing todo with the update.

Jump to

Keyboard shortcuts

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