taskwarrior

package module
v0.0.0-...-deed50d Latest Latest
Warning

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

Go to latest
Published: Oct 1, 2023 License: MIT Imports: 11 Imported by: 2

README

go-taskwarrior

Build Status codecov GoDoc

Golang API for taskwarrior database.

Features

  • Custom parser for .taskrc configuration files
  • Read access to taskwarrior database
  • Adding/modifying existing tasks

Quickstart

Example program to read the current user's tasks:

package main

import (
	"github.com/jubnzv/go-taskwarrior"
)

func main() {

	tw, _ := taskwarrior.NewTaskWarrior("~/.taskrc")
	tw.FetchAllTasks()
	tw.PrintTasks()
}

To add new task initialize Task object with desired values and use:

tw.Add(newTask)
tw.Commit() // Save changes

For more samples see examples directory and package tests.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TASKRC = PathExpandTilda("~/.taskrc")

TASKRC is the default configuration path.

Functions

func GetAvailableKeys

func GetAvailableKeys() []string

GetAvailableKeys returns list of available configuration options represented by TaskRC structure fields.

func PathExpandTilda

func PathExpandTilda(path string) string

PathExpandTilda expands tilda in filepath as $HOME of current user.

func StripComments

func StripComments(line string) string

StripComments remove commented part of input string.

Types

type Task

type Task struct {
	Description string           `json:"description"`
	Project     string           `json:"project,omitempty"`
	Status      string           `json:"status"`
	Uuid        string           `json:"uuid"`
	Urgency     float32          `json:"urgency,omitempty"`
	Priority    string           `json:"priority,omitempty"`
	Due         string           `json:"due,omitempty"`
	End         string           `json:"end,omitempty"`
	Entry       string           `json:"entry,omitempty"`
	Modified    string           `json:"modified,omitempty"`
	Annotations []TaskAnnotation `json:"annotations,omitempty"`
}

Task representation.

type TaskAnnotation

type TaskAnnotation struct {
	Entry       string `json:"entry"`
	Description string `json:"description"`
}

TaskAnnotation representation of an annotation

type TaskRC

type TaskRC struct {
	ConfigPath   string // Location of this .taskrc
	DataLocation string `taskwarrior:"data.location"`
}

TaskRC describes configuration file entries that currently supported by this library.

func ParseTaskRC

func ParseTaskRC(configPath string) (*TaskRC, error)

ParseTaskRC returns new TaskRC struct instance that contains fields with given configuration file values.

func (*TaskRC) MapTaskRC

func (c *TaskRC) MapTaskRC(buf string) error

MapTaskRC maps buffer values to given TaskRC struct.

type TaskWarrior

type TaskWarrior struct {
	Config *TaskRC // Configuration options
	Tasks  []Task  // Task JSON entries
}

TaskWarrior rpresents a single taskwarrior instance

func NewTaskWarrior

func NewTaskWarrior(configPath string) (*TaskWarrior, error)

NewTaskWarrior create new empty TaskWarrior instance.

func (*TaskWarrior) AddTask

func (tw *TaskWarrior) AddTask(task *Task)

AddTask adds new Task entry to given TaskWarrior.

func (*TaskWarrior) Commit

func (tw *TaskWarrior) Commit() error

Commit save current changes of given TaskWarrior instance.

func (*TaskWarrior) FetchAllTasks

func (tw *TaskWarrior) FetchAllTasks() error

FetchAllTasks fetchs all tasks for given TaskWarrior with system `taskwarrior` command call.

func (*TaskWarrior) PrintTasks

func (tw *TaskWarrior) PrintTasks()

PrintTasks pretty print for all tasks represented in given TaskWarrior.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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