Go to file
Brian Buller 239b7c535c Do not ignore comment lines by default
The default behavior should probably be the standard behavior
2019-02-04 04:38:59 +00:00
testdata fix overdue test case 2018-01-01 11:29:49 +01:00
.gitignore Initial commit 2014-01-02 15:04:33 -08:00
.travis.yml added travis-ci build status 2014-01-03 20:08:05 +01:00
example_test.go added Complete() and Reopen() to Task. 2014-01-04 14:13:37 +01:00
LICENSE initial commit, begin working on library 2014-01-03 01:29:54 +01:00
README.md Update README.md 2016-12-25 19:21:23 +01:00
sort_test.go forgot header 2014-01-04 16:11:31 +01:00
sort.go added Complete() and Reopen() to Task. 2014-01-04 14:13:37 +01:00
task_test.go Work in progress 2014-01-13 15:37:21 +01:00
task.go Added new methods on TaskList. 2014-01-13 20:27:58 +01:00
todo.txt work in progress 2014-01-03 17:35:38 +01:00
todotxt_test.go GetTask bugfix 2014-01-16 12:18:21 +01:00
todotxt.go Do not ignore comment lines by default 2019-02-04 04:38:59 +00:00

go-todotxt

A Go todo.txt library.

GoDoc Build Status

The todotxt package is a Go client library for Gina Trapani's todo.txt files. It allows for parsing and manipulating of task lists and tasks in the todo.txt format.

Installation

$ go get github.com/JamesClonk/go-todotxt

Requirements

go-todotxt requires Go1.1 or higher.

Usage

	package main

	import (
		"fmt"
		"github.com/JamesClonk/go-todotxt"
		"log"
	)

	func main() {
		todotxt.IgnoreComments = false

		tasklist, err := todotxt.LoadFromFilename("todo.txt")
		if err != nil {
			log.Fatal(err)
		}

		// tasklist now contains a slice of Tasks
		fmt.Printf("Task 2, todo: %v\n", tasklist[1].Todo)
		fmt.Printf("Task 3: %v\n", tasklist[2])
		fmt.Printf("Task 4, has priority: %v\n\n", tasklist[3].HasPriority())
		fmt.Print(tasklist)

		// Filter list to get only completed tasks
		completedList := tasklist.Filter(func(t Task) bool {
			return t.Completed 
		})
		fmt.Print(completedList)

		// Add a new empty Task to tasklist
		task := NewTask()
		tasklist.AddTask(&task)

		// Or a parsed Task from a string
		parsedTask, _ := ParseTask("x (C) 2014-01-01 Create golang library documentation @Go +go-todotxt due:2014-01-12")
		tasklist.AddTask(parsed)

		// Update an existing task
		task, _ := tasklist.GetTask(2) // Task pointer
		task.Todo = "Do something different.."
		tasklist.WriteToFilename("todo.txt")
	}

Documentation

See GoDoc - Documentation for further documentation.

License

The source files are distributed under the Mozilla Public License, version 2.0, unless otherwise noted.
Please read the FAQ if you have further questions regarding the license.