41 lines
919 B
Go
41 lines
919 B
Go
package task
|
|
|
|
import (
|
|
"encoding/json"
|
|
"sort"
|
|
"log"
|
|
"os/exec"
|
|
)
|
|
|
|
// Task representation.
|
|
type Task struct {
|
|
Id int `json:"id"`
|
|
Description string `json:"description"`
|
|
Tags []string `json:"tags"`
|
|
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"`
|
|
}
|
|
|
|
func GetTasks() []Task {
|
|
out, err := exec.Command("task", "(status:pending -backlog -BLOCKED -idea)", "export").Output()
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
var tasks []Task
|
|
err = json.Unmarshal([]byte(out), &tasks)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
sort.Slice(tasks, func(i, j int) bool {
|
|
return tasks[i].Urgency > tasks[j].Urgency
|
|
})
|
|
return tasks
|
|
}
|