taskercli

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2022 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	VERSION     string = "1.0"
	DATE_FORMAT string = "2006-01-02"
)

current version and date format of taskercli

View Source
const (
	AddEvent    = "EventAdded"
	UpdateEvent = "EventUpdated"
	DeleteEvent = "EventDeleted"
)

the different types of events that can occur

View Source
const (
	Daily    = "daily"
	Weekdays = "weekdays"
	Weekly   = "weekly"
	Monthly  = "monthly"
	Yearly   = "yearly"
)
View Source
const TodosJSONFile = ".todos.json"

name of the todo file

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

Types

type App

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

App is giving the structure of the taskercli

func NewApp

func NewApp() *App

NewApp is creating a new tasker 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 todo 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 from the todo list

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()

Initialize is initializing the taskercli 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 date struct of todo for sorting todo items by date

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 EventLog

type EventLog struct {
	EventType    string `json:"event_type"`
	ObjectType   string `json:"object_type"`
	TodoListUUID string `json:"todo_list_uuid"`
	Object       *Todo  `json:"object"`
}

EventLog is a log of events that occurred, with the todo data.

type EventLogger

type EventLogger struct {
	PreviousTodoList  *TodoList
	CurrentTodoList   *TodoList
	Store             Store
	SyncedLists       []*SyncedList
	CurrentSyncedList *SyncedList
	Events            []*EventLog
}

EventLogger is the main struct of this file

func NewEventLogger

func NewEventLogger(todolist *TodoList, store Store) *EventLogger

NewEventLogger is creating a new event logger

type FileStore

type FileStore struct {
	Loaded bool
}

FileStore is the struct for the file store

func NewFileStore

func NewFileStore() *FileStore

NewFileStore is creating a new file store

func (*FileStore) GetLocation

func (f *FileStore) GetLocation() string

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

func (*FileStore) Initialize

func (f *FileStore) Initialize()

Initialize is initializing a new .toos.json file

func (*FileStore) Load

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

Load is loading the todos from the .todos.json file either from the current dir or from the home dir

func (*FileStore) LocalTodosFileExists

func (f *FileStore) LocalTodosFileExists() bool

Returns true if the .todos.json file exists in the current dir

func (*FileStore) Save

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

Save is saving the todos to the .todos.json file

type Filter

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

	Due       string
	DueBefore string
	DueAfter  string

	Contexts []string
	Projects []string
	Status   []string

	ExcludeContexts []string
	ExcludeProjects []string
	ExcludeStatus   []string

	CompletedAt []string

	HasCompleted   bool
	HasCompletedAt bool
	HasArchived    bool
	HasIsPriority  bool

	HasDueBefore bool
	HasDue       bool
	HasDueAfter  bool

	HasStatus        bool
	HasProjectFilter bool
	HasContextFilter bool

	HasRecur   bool
	Recur      string
	RecurUntil 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 storing the grouped todos

type Grouper

type Grouper struct{}

Grouper is the group struct

func (*Grouper) GroupByContext

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

GroupByContext is grouping todos by its context.

func (*Grouper) GroupByNothing

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

GroupByNothing is the default result if todos are not grouped by context 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

type InputParser

type InputParser 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 a printer that prints to the console

func (*MemoryPrinter) Print

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

Print prints the grouped todo list to the console

type MemoryStore

type MemoryStore struct {
	Todos []*Todo
}

MemoryStore is a store that stores the todo list in memory

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore creates a new MemoryStore that returns a pointer to a new MemoryStore

func (*MemoryStore) GetLocation

func (m *MemoryStore) GetLocation() string

Get Location of the memory store

func (*MemoryStore) Initialize

func (m *MemoryStore) Initialize()

Init initializes the MemoryStore

func (*MemoryStore) Load

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

Load loads the todo list from the MemoryStore

func (*MemoryStore) LocalTodosFileExists

func (m *MemoryStore) LocalTodosFileExists() bool

Check if LocalTodoFileExists

func (*MemoryStore) Save

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

Save saves the todo list to the MemoryStore

type Printer

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

Printer is an interface for printing the output of grouped todos

type Recurrence

type Recurrence struct{}

Recurrence struct for 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 tasker 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 tasker to the terminal screen.

type SimpleScreenPrinter

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

SimpleScreenPrinter is a printer that prints to the console

func NewSimpleScreenPrinter

func NewSimpleScreenPrinter(unicodeSupport bool) *SimpleScreenPrinter

NewScreenPrinter creates a new screen printer

func (*SimpleScreenPrinter) Print

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

Print prints the output to the terminal

type Store

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

Store is the interface for the taskercli todos.

type SyncedList

type SyncedList struct {
	Filename string      `json:"filename"`
	UUID     string      `json:"uuid"`
	Name     string      `json:"name"`
	Events   []*EventLog `json:"events"`
}

type Todo

type Todo struct {
	ID                int      `json:"id"`
	UUID              string   `json:"uuid"`
	Subject           string   `json:"subject"`
	Projects          []string `json:"projects"`
	Contexts          []string `json:"contexts"`
	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"`
}

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)

func NewTodo

func NewTodo() *Todo

NewTodo is creating a new todo item

func (*Todo) Archive

func (t *Todo) Archive()

Archive archives a todo item

func (Todo) CalculateDueTime

func (t Todo) CalculateDueTime() time.Time

CalculateDueDate calculates the due date for a todo item

func (*Todo) Complete

func (t *Todo) Complete()

Complete marks a todo item as completed with the current time

func (Todo) CompletedDateToDate

func (t Todo) CompletedDateToDate() string

CompletedDate returns the completed date of a todo item

func (Todo) Equals

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

Equals returns true if two todo items are equal

func (Todo) HasNotes

func (t Todo) HasNotes() bool

HasNotes returns true if a todo item has notes

func (*Todo) Prioritize

func (t *Todo) Prioritize()

Priority prioritizes a todo item

func (*Todo) Unarchive

func (t *Todo) Unarchive()

Unarchive unarchives a todo item

func (*Todo) Uncomplete

func (t *Todo) Uncomplete()

func (*Todo) Unprioritize

func (t *Todo) Unprioritize()

Unpriority unprioritizes a todo item

func (Todo) Valid

func (t Todo) Valid() bool

Valid checks 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"`
	Data []*Todo `json:"todo_items_attributes"`
}

TodoList is the struct for a todo list with multiple 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 by their ids from todo list

func (*TodoList) Complete

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

Complete is a variadic function completing multiple todos by their ids

func (*TodoList) Delete

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

Delete is a variadic function deleting multiple todos from a todo list by their ids

func (*TodoList) FindByID

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

FindByID finds a todo by ID.

func (*TodoList) GarbageCollector

func (t *TodoList) GarbageCollector()

GarbageCollector is a function that cleans up the todo list by removing archived todos

func (*TodoList) IndexOf

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

IndexOf returns the index of a todo item

func (*TodoList) Load

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

Load is loading the todo list

func (*TodoList) MaxID

func (t *TodoList) MaxID() int

MaxID returns the max id for a todo item

func (*TodoList) NextID

func (t *TodoList) NextID() int

NextID returns the next id for a todo item

func (*TodoList) Prioritize

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

Prioritize is prioritizing multiple todos by their ids from todo list

func (*TodoList) SetStatus

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

SetStatus is setting the status of multiple todos by their ids from todo list along with the status

func (*TodoList) Todos

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

Sorted list of Todos

func (*TodoList) Unarchive

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

Unarchive is unarchiving multiple todos by their ids from todo list

func (*TodoList) Uncomplete

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

Uncomplete is a variadic function uncompleting multiple todos by their ids

func (*TodoList) Unprioritize

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

Unprioritize is unprioritizing multiple todos by their ids from todo list

Jump to

Keyboard shortcuts

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