taskwarrior

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

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

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")

Default configuration path.

Functions

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.

Types

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.

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
t or T : Toggle theme light dark auto
y or Y : Canonical URL