updated Readme.md
This commit is contained in:
parent
2e04f1d233
commit
dbb967d319
16
README.md
16
README.md
@ -35,16 +35,30 @@ go-todotxt requires Go1.1 or higher.
|
||||
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 := testTasklist.Filter(func(t Task) bool {
|
||||
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")
|
||||
}
|
||||
```
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user