Allow filtering on complete/incomplete

e.g.:
List all completed tasks
`gask ls :x`
List all incomplete tasks
`gask ls :o`
This commit is contained in:
Brian Buller 2021-03-18 09:27:31 -05:00
parent 1b62cbe2d8
commit 00e13fc7ad

View File

@ -121,6 +121,15 @@ func (a *AppState) getFilterPredicate(filter string) func(todotxt.Task) bool {
}
filterParts := strings.Split(filter, " ")
for _, part := range filterParts {
if part == ":x" {
predicates = append(predicates, func(t todotxt.Task) bool {
return t.Completed
})
} else if part == ":-x" || part == ":o" {
predicates = append(predicates, func(t todotxt.Task) bool {
return !t.Completed
})
}
if strings.HasPrefix(part, "@") {
predicates = append(predicates, func(t todotxt.Task) bool {
for _, v := range t.Contexts {