Documentation
¶
Overview ¶
lib holds the core logic for working with tasks and connecting to the underlying taks database.
Index ¶
- Constants
- Variables
- func GetConfigDir(p string) (string, error)
- type AppMetadata
- type TaksDB
- func (db *TaksDB) Close() error
- func (db *TaksDB) DeleteMetadata() error
- func (db *TaksDB) DeleteTask(id string) error
- func (db *TaksDB) GetMetadata() (*AppMetadata, error)
- func (db *TaksDB) GetTask(id string) (*Task, error)
- func (db *TaksDB) ListTasks() ([]*Task, error)
- func (db *TaksDB) NewTaskID() (uint64, error)
- func (db *TaksDB) PutMetadata(m *AppMetadata) error
- func (db *TaksDB) PutTask(t *Task) error
- func (db *TaksDB) Validate() error
- type Task
- type TaskPriority
Constants ¶
const (
ConfigDirName = ".taks/"
)
const CurrentMetadataVersion int = 0
const TaskPrefix = "task-"
Variables ¶
var MetadataID = []byte("_metadata")
Functions ¶
func GetConfigDir ¶
GetConfigDir returns the path to the config directory where the database should be stored. `p` is the path to the parent directory, in which the config directory will be named after `ConfigDirName`. If `p` is empty, the config directory will be created in the user's home directory (per `os.UserHomeDir()`).
Types ¶
type AppMetadata ¶
type AppMetadata struct {
Version int
}
AppMetadata stores metadata about the
func MetadataFromBytes ¶
func MetadataFromBytes(b []byte) (*AppMetadata, error)
func NewMetadata ¶
func NewMetadata() *AppMetadata
func (*AppMetadata) MarshalBytes ¶
func (m *AppMetadata) MarshalBytes() (id []byte, body []byte, err error)
type TaksDB ¶
TaksDB manages the connection to the task DB
func (*TaksDB) DeleteMetadata ¶
func (*TaksDB) DeleteTask ¶
func (*TaksDB) GetMetadata ¶
func (db *TaksDB) GetMetadata() (*AppMetadata, error)
func (*TaksDB) PutMetadata ¶
func (db *TaksDB) PutMetadata(m *AppMetadata) error
type Task ¶
type Task struct {
ID string `json:"id"` // Unique ID for the task, used as the DB key
Name string `json:"name"` // Name of the task & main text
Details string `json:"details,omitempty"` // Optional task details
Project string `json:"project,omitempty"` // Optional project name associated with the task
Status string `json:"status,omitempty"` // Optional task status
Priority TaskPriority `json:"priority,omitempty"` // Optional task priority (Priority scale: 1-5; 1 is the highest; 0 means not set)
CreatedAt time.Time `json:"createdAt"` // Timestamp of the task creation
DueAt *time.Time `json:"dueAt,omitempty"` // Optional due date for the task
CompletedAt *time.Time `json:"completedAt,omitempty"` // Optional completion timestamp
Tags []string `json:"tags"` // Optional list of tags associated with the task
}
Task stores data connected to a single task in the user's task list.
func NewTask ¶
NewTask creates a new Task with the supplied name, an auto-generated ID and creation timestamp, and nil values for the remaining fields.
func TaskFromBytes ¶
TaskFromBytes unmarshals the given byte slices into a Task.
func (*Task) IsComplete ¶
func (*Task) MarshalBytes ¶
MarshalBytes returns the the task's ID and JSON-encoded data as byte slices.
type TaskPriority ¶
type TaskPriority uint32
TaskPriority is an enum for the priority of a task.
const ( TaskPriorityNotSet TaskPriority = iota // An unset priority. TaskPriorityVeryHigh // Very high priority. TaskPriorityHigh // High priority. TaskPriorityMedium // Medium priority. TaskPriorityLow // Low priority. TaskPriorityVeryLow // Very low priority. )