Documentation ¶
Overview ¶
Package data defines the structures and function to manage the data
Index ¶
- func TaskFilterAll(task Task) bool
- func TaskFilterDoing(task Task) bool
- func TaskFilterDone(task Task) bool
- func TaskFilterOnBoard(task Task) bool
- func TaskFilterTodo(task Task) bool
- func TreeString(tasks TaskArray) string
- type Task
- type TaskArray
- type TaskFilter
- type TaskID
- type TaskIDArray
- type TaskJournal
- func (journal *TaskJournal) Add(task Task) error
- func (journal *TaskJournal) AddOnBoard(uindex TaskID) error
- func (journal *TaskJournal) Delete(uindex TaskID) (Task, error)
- func (journal *TaskJournal) File() string
- func (journal TaskJournal) GetFreeUID() TaskID
- func (journal *TaskJournal) GetNoteFile(uindex TaskID) (string, error)
- func (journal *TaskJournal) GetOrCreateNoteFile(uindex TaskID) (string, error)
- func (journal TaskJournal) GetTask(uindex TaskID) (*Task, error)
- func (journal TaskJournal) GetTaskInfo(uindex TaskID) (string, error)
- func (journal TaskJournal) GetTasksWithFilter(filter TaskFilter) []*Task
- func (journal TaskJournal) List() string
- func (journal TaskJournal) ListWithFilter(taskFilter TaskFilter) string
- func (journal *TaskJournal) Load(filepath string) error
- func (journal *TaskJournal) LoadOrCreate(filepath string) error
- func (journal *TaskJournal) New(text string) *Task
- func (journal *TaskJournal) RemoveFromBoard(uindex TaskID) error
- func (journal *TaskJournal) Save() error
- func (journal *TaskJournal) SaveTo(filepath string) error
- func (journal TaskJournal) String() string
- func (journal TaskJournal) Tree() string
- type TaskStatus
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func TaskFilterAll ¶
TaskFilterAll always returns true (no filter)
func TaskFilterDoing ¶
TaskFilterDoing returns true if the task is doing
func TaskFilterDone ¶
TaskFilterDone returns true if the task is done
func TaskFilterOnBoard ¶
TaskFilterOnBoard returns true if the task is on board
func TaskFilterTodo ¶
TaskFilterTodo returns true if the task is todo
func TreeString ¶
TreeString returns a tree representation of the dataArray
Types ¶
type Task ¶
type Task struct { UIndex TaskID // Usage Index (could be recycled) GIndex TaskID // Global Index (invariant and unique) Timestamp int64 // Date of the task (unix format) Description string // Description of the Task Status TaskStatus // Status of the task OnBoard bool // True if the task is on board NotePath string // Path to the note file (relative to the db root) ParentID TaskID // UID of the parent task }
Task is the data structure for a single task
func CreateTestTask ¶
CreateTestTask creates a dummy task for test purposes
func (Task) InfoString ¶
InfoString returns a string representation of the task attributes
func (Task) JSONString ¶
JSONString returns a json string representation of this task
func (Task) OnelineString ¶
OnelineString returns a string representation of this task on one signe line. This shouldbe used for a pretty presentation of task lists.
type TaskFilter ¶
TaskFilter defines a function that can be used to filter a list of task considering the return value (true or false) of the TaskFilter function.
type TaskID ¶
type TaskID uint64
TaskID is the data type of a task index (Usage ID or General ID)
const ( // NoUID is used to specify that there is no task index (task identifier) NoUID TaskID = 0 )
type TaskIDArray ¶
type TaskIDArray []TaskID
TaskIDArray is a list of TaskID
func (*TaskIDArray) Set ¶
func (il *TaskIDArray) Set(value string) error
Set implement the flag.Value interface
func (*TaskIDArray) String ¶
func (il *TaskIDArray) String() string
String implement the flag.Value interface
type TaskJournal ¶
type TaskJournal struct { TaskList TaskArray // contains filtered or unexported fields }
TaskJournal defines the structure to manage a task journal. A tasks journal could be the current collection of tasks (called journal) or the archive collection of tasks (called archive).
func CreateTestJournal ¶
func CreateTestJournal() TaskJournal
CreateTestJournal creates a dummy journal for test purposes
func (*TaskJournal) Add ¶
func (journal *TaskJournal) Add(task Task) error
Add adds the given task to this journal
func (*TaskJournal) AddOnBoard ¶
func (journal *TaskJournal) AddOnBoard(uindex TaskID) error
AddOnBoard adds the specified task on board
func (*TaskJournal) Delete ¶
func (journal *TaskJournal) Delete(uindex TaskID) (Task, error)
Delete removes the task with the specified id. Returns a copy of the deleted task on success
func (*TaskJournal) File ¶
func (journal *TaskJournal) File() string
File returns the persistance filepath (if journal is created by Load)
func (TaskJournal) GetFreeUID ¶
func (journal TaskJournal) GetFreeUID() TaskID
GetFreeUID returns the next free usage index in this journal
func (*TaskJournal) GetNoteFile ¶
func (journal *TaskJournal) GetNoteFile(uindex TaskID) (string, error)
GetNoteFile returns the filepath to the note associated to this task. Returns a blank string ("") if no note is associated to this task.
func (*TaskJournal) GetOrCreateNoteFile ¶
func (journal *TaskJournal) GetOrCreateNoteFile(uindex TaskID) (string, error)
GetOrCreateNoteFile returns the filepath to the note associated to this task. It ensures that this note exists. If it is not defined, then the function creates it and return the absolute path to this note file.
func (TaskJournal) GetTask ¶
func (journal TaskJournal) GetTask(uindex TaskID) (*Task, error)
GetTask returns a pointer to the task whose usage ID is uindex
func (TaskJournal) GetTaskInfo ¶
func (journal TaskJournal) GetTaskInfo(uindex TaskID) (string, error)
GetTaskInfo returns a string representation of the charateristics of this task. This is the journal that creates this string and not the task itself, so that we can use absolute paths
func (TaskJournal) GetTasksWithFilter ¶
func (journal TaskJournal) GetTasksWithFilter(filter TaskFilter) []*Task
GetTasksWithFilter returns an array of pointer to the tasks that satisfy the given filter.
func (TaskJournal) List ¶
func (journal TaskJournal) List() string
List returns a string representation of the list of all tasks (no filter)
func (TaskJournal) ListWithFilter ¶
func (journal TaskJournal) ListWithFilter(taskFilter TaskFilter) string
ListWithFilter returns a string representation of the list of tasks that satisfy the given filter (tasks are included in the list if the taskFilter returns true).
func (*TaskJournal) Load ¶
func (journal *TaskJournal) Load(filepath string) error
Load reads a journal of tasks from the given file. Returns an error if the file does not exist. Use LoadOrCreate to make sure to initialise a joournal whatever the starting situation (inn the case of the first usage of todo for example). It implements the jsonable interface.
func (*TaskJournal) LoadOrCreate ¶
func (journal *TaskJournal) LoadOrCreate(filepath string) error
LoadOrCreate tries to load a journal from the given file, and create a void journal if the file does not exist.
func (*TaskJournal) New ¶
func (journal *TaskJournal) New(text string) *Task
New creates a new task in the database
func (*TaskJournal) RemoveFromBoard ¶
func (journal *TaskJournal) RemoveFromBoard(uindex TaskID) error
RemoveFromBoard removes the specified task from board
func (*TaskJournal) Save ¶
func (journal *TaskJournal) Save() error
Save writes the journal data to the persistence file
func (*TaskJournal) SaveTo ¶
func (journal *TaskJournal) SaveTo(filepath string) error
SaveTo writes the journal data to the given file. It implements the jsonable interface.
func (TaskJournal) String ¶
func (journal TaskJournal) String() string
func (TaskJournal) Tree ¶
func (journal TaskJournal) Tree() string
Tree returns a string representation of the tree structure of tasks (parent relations)
type TaskStatus ¶
type TaskStatus int
TaskStatus is an index of the step of completion of a task
const ( StatusTodo TaskStatus = 0 StatusDoing TaskStatus = 1 StatusDone TaskStatus = 2 StatusStart TaskStatus = StatusTodo StatusEnd TaskStatus = StatusDone )
Enumeration of possible TaskStatus
func (TaskStatus) Label ¶
func (status TaskStatus) Label() string
Label returns a string representation of this status
func (*TaskStatus) Next ¶
func (status *TaskStatus) Next() error
Next makes the status change to its next state
func (*TaskStatus) Previous ¶
func (status *TaskStatus) Previous() error
Previous makes the status change to its previous state
func (TaskStatus) String ¶
func (status TaskStatus) String() string
func (*TaskStatus) Value ¶
func (status *TaskStatus) Value(label string) error
Value sets the status value from its string label