Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
97a991fa26 | ||
|
e5c37a1106 | ||
|
dbb967d319 |
18
README.md
18
README.md
@@ -3,7 +3,7 @@ go-todotxt
|
|||||||
|
|
||||||
A Go todo.txt library.
|
A Go todo.txt library.
|
||||||
|
|
||||||
[](https://godoc.org/github.com/JamesClonk/go-todotxt) [](https://travis-ci.org/JamesClonk/go-todotxt) [](http://codebot.io/doc/pkg/github.com/JamesClonk/go-todotxt "Codebot") [](https://bitdeli.com/free "Bitdeli Badge")
|
[](https://godoc.org/github.com/JamesClonk/go-todotxt) [](https://travis-ci.org/JamesClonk/go-todotxt)
|
||||||
|
|
||||||
The *todotxt* package is a Go client library for Gina Trapani's [todo.txt](https://github.com/ginatrapani/todo.txt-cli/) files.
|
The *todotxt* package is a Go client library for Gina Trapani's [todo.txt](https://github.com/ginatrapani/todo.txt-cli/) files.
|
||||||
It allows for parsing and manipulating of task lists and tasks in the todo.txt format.
|
It allows for parsing and manipulating of task lists and tasks in the todo.txt format.
|
||||||
@@ -35,16 +35,30 @@ go-todotxt requires Go1.1 or higher.
|
|||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// tasklist now contains a slice of Tasks
|
||||||
fmt.Printf("Task 2, todo: %v\n", tasklist[1].Todo)
|
fmt.Printf("Task 2, todo: %v\n", tasklist[1].Todo)
|
||||||
fmt.Printf("Task 3: %v\n", tasklist[2])
|
fmt.Printf("Task 3: %v\n", tasklist[2])
|
||||||
fmt.Printf("Task 4, has priority: %v\n\n", tasklist[3].HasPriority())
|
fmt.Printf("Task 4, has priority: %v\n\n", tasklist[3].HasPriority())
|
||||||
fmt.Print(tasklist)
|
fmt.Print(tasklist)
|
||||||
|
|
||||||
// Filter list to get only completed tasks
|
// Filter list to get only completed tasks
|
||||||
completedList := testTasklist.Filter(func(t Task) bool {
|
completedList := tasklist.Filter(func(t Task) bool {
|
||||||
return t.Completed
|
return t.Completed
|
||||||
})
|
})
|
||||||
fmt.Print(completedList)
|
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")
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
2
testdata/ouput_todo.txt
vendored
2
testdata/ouput_todo.txt
vendored
@@ -1,6 +1,6 @@
|
|||||||
2013-02-22 Pick up milk @GroceryStore
|
2013-02-22 Pick up milk @GroceryStore
|
||||||
x Download Todo.txt mobile app @Phone
|
x Download Todo.txt mobile app @Phone
|
||||||
(B) 2013-12-01 Outline chapter 5 @Computer +Novel Level:5 private:false due:2014-02-17
|
(C) 2013-12-01 Go home! @Computer +Novel Level:5 private:false due:2011-11-11
|
||||||
x 2014-01-02 (B) 2013-12-30 Create golang library test cases @Go +go-todotxt
|
x 2014-01-02 (B) 2013-12-30 Create golang library test cases @Go +go-todotxt
|
||||||
x 2014-01-03 2014-01-01 Create some more golang library test cases @Go +go-todotxt
|
x 2014-01-03 2014-01-01 Create some more golang library test cases @Go +go-todotxt
|
||||||
(B) 2013-12-01 Outline chapter 5 @Computer +Novel Level:5 private:false due:2014-02-17
|
(B) 2013-12-01 Outline chapter 5 @Computer +Novel Level:5 private:false due:2014-02-17
|
||||||
|
2
testdata/task_todo.txt
vendored
2
testdata/task_todo.txt
vendored
@@ -57,7 +57,7 @@ x 2014-01-03 2014-01-01 Create some more golang library test cases @Go +go-todot
|
|||||||
|
|
||||||
# Overdue test cases
|
# Overdue test cases
|
||||||
x 2014-01-04 (B) 2013-12-30 Create golang library @Go +go-todotxt due:2014-01-02
|
x 2014-01-04 (B) 2013-12-30 Create golang library @Go +go-todotxt due:2014-01-02
|
||||||
(B) 2013-12-01 private:false Outline chapter 5 +Novel @Computer due:2017-07-17 Level:5
|
(B) 2013-12-01 private:false Outline chapter 5 +Novel @Computer due:2027-07-17 Level:5
|
||||||
Research self-publishing services +Novel +Novel +Novel due:2014-01-01
|
Research self-publishing services +Novel +Novel +Novel due:2014-01-01
|
||||||
x 2014-01-03 2014-01-01 Create some more golang library test cases @Go +go-todotxt
|
x 2014-01-03 2014-01-01 Create some more golang library test cases @Go +go-todotxt
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user