package module
Version: v0.0.0-...-22add02 Latest Latest

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

Go to latest
Published: Nov 6, 2018 License: MIT Imports: 11 Imported by: 6



Build Status codecov GoDoc

Golang API for taskwarrior database.


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


Example program to read the current user's tasks:

package main

import (

func main() {

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

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

tw.Commit() // Save changes

For more samples see examples directory and package tests.




This section is empty.


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

Default configuration path.


func GetAvailableKeys

func GetAvailableKeys() []string

Return list of available configuration options represented by TaskRC structure fields.

func PathExpandTilda

func PathExpandTilda(path string) string

Expand tilda in filepath as $HOME of current user.

func StripComments

func StripComments(line string) string

Remove commented part of input string.


type Task

type Task struct {
	Description string  `json:"description"`
	Project     string  `json:"project"`
	Status      string  `json:"status"`
	Uuid        string  `json:"uuid"`
	Urgency     float32 `json:"urgency"`
	Priority    string  `json:"priority"`
	Due         string  `json:"due"`
	End         string  `json:"end"`
	Entry       string  `json:"entry"`
	Modified    string  `json:"modified"`

Task representation.

type TaskRC

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

Describes configuration file entries that currently supported by this library.

func ParseTaskRC

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

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

func (*TaskRC) MapTaskRC

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

Map buffer values to given TaskRC struct.

type TaskWarrior

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

Represents a single taskwarrior instance.

func NewTaskWarrior

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

Create new empty TaskWarrior instance.

func (*TaskWarrior) AddTask

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

Add new Task entry to given TaskWarrior.

func (*TaskWarrior) Commit

func (tw *TaskWarrior) Commit() error

Save current changes of given TaskWarrior instance.

func (*TaskWarrior) FetchAllTasks

func (tw *TaskWarrior) FetchAllTasks() error

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

func (*TaskWarrior) PrintTasks

func (tw *TaskWarrior) PrintTasks()

Pretty print for all tasks represented in given TaskWarrior.


Path Synopsis

Jump to

Keyboard shortcuts

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