ultodo

package
v0.0.0-...-983292a Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2023 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Current version of ultodo.
	VERSION string = "1.7.2"

	DATE_FORMAT string = "2006-01-02"
)
View Source
const (
	Daily    = "daily"
	Weekdays = "weekdays"
	Weekly   = "weekly"
	Monthly  = "monthly"
	Yearly   = "yearly"
)
View Source
const TodosJSONFile = ".todos.json"

TodosJSONFile is the filename to store todos in

Variables

This section is empty.

Functions

func AddIfNotThere

func AddIfNotThere(arr []string, items []string) []string

AddIfNotThere is appending an item to an array if the item is not already present.

func EditTodo

func EditTodo(todo *Todo, todoList *TodoList, filter *Filter) error

EditTodo edits a todo based upon a filter

func UserHomeDir

func UserHomeDir() string

UserHomeDir returns the home dir of the current user.

Types

type App

type App struct {
	// EventLogger *EventLogger
	TodoStore Store
	Printer   Printer
	TodoList  *TodoList
}

App is the giving you the structure of the ultodo app.

func NewApp

func NewApp() *App

NewApp is creating a new ultodo app.

func NewAppWithPrintOptions

func NewAppWithPrintOptions(unicodeSupport bool, colorSupport bool) *App

NewAppWithPrintOptions creates a new app with options for printing on screen.

func (*App) AddNote

func (a *App) AddNote(todoID int, note string)

AddNote adds a note to a todo.

func (*App) AddTodo

func (a *App) AddTodo(input string)

AddTodo adds a new todo to the current list

func (*App) ArchiveCompleted

func (a *App) ArchiveCompleted()

ArchiveCompleted will archive all completed todos.

func (*App) ArchiveTodo

func (a *App) ArchiveTodo(input string)

ArchiveTodo archives a todo.

func (*App) CompleteTodo

func (a *App) CompleteTodo(input string, archive bool)

CompleteTodo completes a todo.

func (*App) DeleteNote

func (a *App) DeleteNote(todoID int, noteID int)

DeleteNote deletes a note from a todo.

func (*App) DeleteTodo

func (a *App) DeleteTodo(input string)

DeleteTodo deletes a todo.

func (*App) EditNote

func (a *App) EditNote(todoID int, noteID int, note string)

EditNote edits a todo's note.

func (*App) EditTodo

func (a *App) EditTodo(todoID int, input string)

EditTodo edits a todo with the given input.

func (*App) GarbageCollect

func (a *App) GarbageCollect()

GarbageCollect will delete all archived todos.

func (*App) InitializeRepo

func (a *App) InitializeRepo()

InitializeRepo is initializing ultodo repo.

func (*App) ListTodos

func (a *App) ListTodos(input string, showNotes bool, showStatus bool)

ListTodos will list all todos.

func (*App) PrioritizeTodo

func (a *App) PrioritizeTodo(input string)

PrioritizeTodo will prioritize a todo.

func (*App) SetTodoStatus

func (a *App) SetTodoStatus(input string)

StartTodo will start a todo.

func (*App) UnarchiveTodo

func (a *App) UnarchiveTodo(input string)

UnarchiveTodo unarchives a todo.

func (*App) UncompleteTodo

func (a *App) UncompleteTodo(input string)

UncompleteTodo uncompletes a todo.

func (*App) UnprioritizeTodo

func (a *App) UnprioritizeTodo(input string)

UnprioritizeTodo unprioritizes a todo.

type ByDate

type ByDate []*Todo

ByDate is the by date struct of a todo.

func (ByDate) Len

func (a ByDate) Len() int

func (ByDate) Less

func (a ByDate) Less(i, j int) bool

func (ByDate) Swap

func (a ByDate) Swap(i, j int)

type DateParser

type DateParser struct{}

DateParser is a thing that parses relative, arbitrary, and absolute dates, and returns a date in the format of yyyy-mm-dd

func (*DateParser) ParseDate

func (dp *DateParser) ParseDate(dateString string, pivotDay time.Time) (date time.Time, err error)

ParseDate takes a date from a Filter and turns it into a string with the format of yyyy-mm-dd

type FileStore

type FileStore struct {
	Loaded bool
}

FileStore is the main struct of this file.

func NewFileStore

func NewFileStore() *FileStore

NewFileStore is creating a new file store.

func (*FileStore) GetLocation

func (f *FileStore) GetLocation() string

GetLocation is returning the location of the .todos.json file.

func (*FileStore) Initialize

func (f *FileStore) Initialize()

Initialize is initializing a new .todos.json file.

func (*FileStore) Load

func (f *FileStore) Load() ([]*Todo, error)

Load is loading a .todos.json file, either from cwd, or the home directory

func (*FileStore) LocalTodosFileExists

func (f *FileStore) LocalTodosFileExists() bool

Returns if a local .todos.json file exists in the current dir.

func (*FileStore) Save

func (f *FileStore) Save(todos []*Todo)

Save is saving a .todos.json file.

type Filter

type Filter struct {
	Subject    string
	Archived   bool
	IsPriority bool
	Completed  bool

	Due       string
	DueBefore string
	DueAfter  string

	Tags     []string
	Projects []string
	Status   []string

	SearchString []string

	ExcludeTags     []string
	ExcludeProjects []string
	ExcludeStatus   []string

	CompletedAt []string

	HasCompleted   bool
	HasCompletedAt bool
	HasArchived    bool
	HasIsPriority  bool

	HasDueBefore bool
	HasDue       bool
	HasDueAfter  bool

	HasSearchString bool

	HasStatus        bool
	HasProjectFilter bool
	HasTagFilter     bool

	HasRecur   bool
	Recur      string
	RecurUntil string
}

Filter holds the parsed filtering results from an input string

func (*Filter) LastStatus

func (f *Filter) LastStatus() string

LastStatus returns the last status from the filter

type GroupedTodos

type GroupedTodos struct {
	Groups map[string][]*Todo
}

GroupedTodos is the main struct of this file.

type Grouper

type Grouper struct{}

Grouper is the group struct.

func (*Grouper) GroupByNothing

func (g *Grouper) GroupByNothing(todos []*Todo) *GroupedTodos

GroupByNothing is the default result if todos are not grouped by tag project.

func (*Grouper) GroupByProject

func (g *Grouper) GroupByProject(todos []*Todo) *GroupedTodos

GroupByProject is grouping todos by its project.

func (*Grouper) GroupByStatus

func (g *Grouper) GroupByStatus(todos []*Todo) *GroupedTodos

GroupByStatus is grouping todos by status

func (*Grouper) GroupByTag

func (g *Grouper) GroupByTag(todos []*Todo) *GroupedTodos

GroupByTag is grouping todos by its tag.

type InputParser

type InputParser struct{}

InputParser parses text to extract a Filter struct

func (*InputParser) Parse

func (p *InputParser) Parse(input string) (*Filter, error)

Parse parses raw input and returns a Filter object

type MemoryPrinter

type MemoryPrinter struct {
	Groups *GroupedTodos
}

MemoryPrinter is the main struct of this file.

func (*MemoryPrinter) Print

func (m *MemoryPrinter) Print(groupedTodos *GroupedTodos, printNotes bool)

Print is printing grouped todos.

type MemoryStore

type MemoryStore struct {
	Todos []*Todo
}

MemoryStore is the main struct of this file.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore is starting new memory store.

func (*MemoryStore) GetLocation

func (m *MemoryStore) GetLocation() string

GetLocation is giving the location of the memory store.

func (*MemoryStore) Initialize

func (m *MemoryStore) Initialize()

Initialize is initializing a new memory store.

func (*MemoryStore) Load

func (m *MemoryStore) Load() ([]*Todo, error)

Load is loading todos from the memory store.

func (*MemoryStore) LocalTodosFileExists

func (m *MemoryStore) LocalTodosFileExists() bool

func (*MemoryStore) Save

func (m *MemoryStore) Save(todos []*Todo)

Save is saving todos to the memory store.

type Printer

type Printer interface {
	Print(*GroupedTodos, bool, bool)
}

Printer is an interface for printing grouped todos.

type Recurrence

type Recurrence struct{}

Recurrence struct contains the logic for dealing with recurring todos.

func (*Recurrence) HasNextRecurringTodo

func (r *Recurrence) HasNextRecurringTodo(todo *Todo) bool

HasNextRecurringTodo determines if a todo has a next recurrence.

func (*Recurrence) NextRecurringTodo

func (r *Recurrence) NextRecurringTodo(todo *Todo, completedDate time.Time) *Todo

NextRecurringTodo generates the next recurring todo from the one passed in.

func (*Recurrence) ValidRecurrence

func (r *Recurrence) ValidRecurrence(input string) bool

ValidRecurrence takes an input string and determines if the value is a valid ultodo recurrence.

type ScreenPrinter

type ScreenPrinter struct {
	Writer         *io.Writer
	UnicodeSupport bool
}

ScreenPrinter is the default struct of this file

func NewScreenPrinter

func NewScreenPrinter(unicodeSupport bool) *ScreenPrinter

NewScreenPrinter creates a new screeen printer.

func (*ScreenPrinter) Print

func (f *ScreenPrinter) Print(groupedTodos *GroupedTodos, printNotes bool, showStatus bool)

Print prints the output of ultodo to the terminal screen.

type SimpleScreenPrinter

type SimpleScreenPrinter struct {
	Writer         *io.Writer
	UnicodeSupport bool
}

ScreenPrinter is the default struct of this file

func NewSimpleScreenPrinter

func NewSimpleScreenPrinter(unicodeSupport bool) *SimpleScreenPrinter

NewScreenPrinter creates a new screeen printer.

func (*SimpleScreenPrinter) Print

func (f *SimpleScreenPrinter) Print(groupedTodos *GroupedTodos, printNotes bool, showStatus bool)

Print prints the output of ultodo to the terminal screen.

type Store

type Store interface {
	GetLocation() string
	LocalTodosFileExists() bool
	Initialize()
	Load() ([]*Todo, error)
	Save(todos []*Todo)
}

Store is the interface for ultodo todos.

type Todo

type Todo struct {
	ID                int      `json:"id"`
	UUID              string   `json:"uuid"`
	Subject           string   `json:"subject"`
	Projects          []string `json:"projects"`
	Tags              []string `json:"tags"`
	Due               string   `json:"due"`
	Completed         bool     `json:"completed"`
	CompletedDate     string   `json:"completed_date"`
	Status            string   `json:"status"`
	Archived          bool     `json:"archived"`
	IsPriority        bool     `json:"is_priority"`
	Notes             []string `json:"notes"`
	Recur             string   `json:"recur"`
	RecurUntil        string   `json:"recur_until"`
	PrevRecurTodoUUID string   `json:"prev_recur_todo_uuid"`
}

Todo is the struct for a todo item.

func AddTodoIfNotThere

func AddTodoIfNotThere(arr []*Todo, item *Todo) []*Todo

AddTodoIfNotThere is appending an todo item to an todo array if the item is not already present.

func CreateTodo

func CreateTodo(filter *Filter) (*Todo, error)

CreateTodo will create a TodoItem from a Filter

func NewTodo

func NewTodo() *Todo

NewTodo is creating a new todo item.

func (*Todo) Archive

func (t *Todo) Archive()

Archive is archiving a todo item.

func (Todo) CalculateDueTime

func (t Todo) CalculateDueTime() time.Time

CalculateDueTime is calculating the due time of the todo item.

func (*Todo) Complete

func (t *Todo) Complete()

Complete is completing a todo item and sets the complete date to the current time.

func (Todo) CompletedDateToDate

func (t Todo) CompletedDateToDate() string

CompletedDateToDate is returning the date when an item was completed.

func (Todo) Equals

func (t Todo) Equals(other *Todo) bool

Equals compares 2 todos for equality.

func (Todo) HasNotes

func (t Todo) HasNotes() bool

HasNotes is showing if an todo has notes.

func (*Todo) Prioritize

func (t *Todo) Prioritize()

Prioritize is prioritizing a todo item.

func (*Todo) Unarchive

func (t *Todo) Unarchive()

Unarchive is unarchiving a todo item.

func (*Todo) Uncomplete

func (t *Todo) Uncomplete()

Uncomplete is uncompleting a todo item and removes the complete date.

func (*Todo) Unprioritize

func (t *Todo) Unprioritize()

Unprioritize is unpriotizing a todo item.

func (Todo) Valid

func (t Todo) Valid() bool

Valid is checking if a new todo is valid or not.

type TodoFilter

type TodoFilter struct {
	Filter *Filter
	Todos  []*Todo
}

TodoFilter filters todos based on patterns.

func (*TodoFilter) ApplyFilter

func (f *TodoFilter) ApplyFilter() []*Todo

ApplyFilter filters todos based on the Filter struct passed in.

type TodoList

type TodoList struct {
	Name string `json:"name"`
	UUID string `json:"uuid"`
	// IsSynced bool
	Data []*Todo `json:"todo_items_attributes"`
}

TodoList is the struct of a list with several todos.

func (*TodoList) Add

func (t *TodoList) Add(todo *Todo)

Add is adding a single todo to a todo list.

func (*TodoList) Archive

func (t *TodoList) Archive(ids ...int)

Archive is archiving multiple todos from a todo list.

func (*TodoList) Complete

func (t *TodoList) Complete(ids ...int)

Complete is completing multiple todos in a todo list.

func (*TodoList) Delete

func (t *TodoList) Delete(ids ...int)

Delete is deleting multiple todos from a todo list.

func (*TodoList) FindByID

func (t *TodoList) FindByID(id int) *Todo

FindByID finds a todo by ID.

func (*TodoList) FindByIDs

func (t *TodoList) FindByIDs(ids []int) []*Todo

FindByID finds a todo by ID.

func (*TodoList) GarbageCollect

func (t *TodoList) GarbageCollect()

GarbageCollect deletes todos which are archived.

func (*TodoList) IndexOf

func (t *TodoList) IndexOf(todoToFind *Todo) int

IndexOf finds the index of a todo.

func (*TodoList) Load

func (t *TodoList) Load(todos []*Todo)

Load is loading a list with several todos.

func (*TodoList) MaxID

func (t *TodoList) MaxID() int

MaxID returns the maximum human readable ID of all todo items.

func (*TodoList) NextID

func (t *TodoList) NextID() int

NextID returns the next human readable ID.

func (*TodoList) Prioritize

func (t *TodoList) Prioritize(ids ...int)

Prioritize is prioritizing multiple todos from a todo list.

func (*TodoList) SetStatus

func (t *TodoList) SetStatus(input string, ids ...int)

SetStatus sets the status of a todo

func (*TodoList) Todos

func (t *TodoList) Todos() []*Todo

Todos is a sorted list of todos.

func (*TodoList) Unarchive

func (t *TodoList) Unarchive(ids ...int)

Unarchive is unarchiving multiple todos from a todo list.

func (*TodoList) Uncomplete

func (t *TodoList) Uncomplete(ids ...int)

Uncomplete is uncompleting multiple todos from a todo list.

func (*TodoList) Unprioritize

func (t *TodoList) Unprioritize(ids ...int)

Unprioritize is unprioritizing multiple todos from a todo list.

Jump to

Keyboard shortcuts

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