data

package
v0.0.0-...-14d79f1 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2019 License: BSD-2-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package data defines the structures and function to manage the data

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TaskFilterAll

func TaskFilterAll(task Task) bool

TaskFilterAll always returns true (no filter)

func TaskFilterDoing

func TaskFilterDoing(task Task) bool

TaskFilterDoing returns true if the task is doing

func TaskFilterDone

func TaskFilterDone(task Task) bool

TaskFilterDone returns true if the task is done

func TaskFilterOnBoard

func TaskFilterOnBoard(task Task) bool

TaskFilterOnBoard returns true if the task is on board

func TaskFilterTodo

func TaskFilterTodo(task Task) bool

TaskFilterTodo returns true if the task is todo

func TreeString

func TreeString(tasks TaskArray) string

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

func CreateTestTask(uindex TaskID, text string) Task

CreateTestTask creates a dummy task for test purposes

func (Task) InfoString

func (task Task) InfoString() string

InfoString returns a string representation of the task attributes

func (Task) JSONString

func (task Task) JSONString() string

JSONString returns a json string representation of this task

func (Task) OnelineString

func (task Task) OnelineString() string

OnelineString returns a string representation of this task on one signe line. This shouldbe used for a pretty presentation of task lists.

func (Task) String

func (task Task) String() string

String returns a string representation of this task

type TaskArray

type TaskArray []Task

TaskArray is the data structure for a list (array) of Tasks

func (TaskArray) String

func (tasks TaskArray) String() string

String implements the stringable interface for a TaskArray

type TaskFilter

type TaskFilter func(task Task) bool

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
)

func (*TaskID) Set

func (taskID *TaskID) Set(value string) error

Set implement the flag.Value interface

func (*TaskID) String

func (taskID *TaskID) String() string

The task indeces are used one the command lines to specify the target of actions, then we give here an implementation of the flag.Value interface for a list of task indeces.

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

Jump to

Keyboard shortcuts

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