Fix UDA colors
This commit is contained in:
@ -23,28 +23,29 @@ func (a Annotation) String() string {
|
||||
}
|
||||
|
||||
type Task struct {
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Project string `json:"project"`
|
||||
Priority string `json:"priority"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
VirtualTags []string `json:"-"`
|
||||
Depends []string `json:"depends,omitempty"`
|
||||
DependsIds string `json:"-"`
|
||||
Urgency float32 `json:"urgency,omitempty"`
|
||||
Parent string `json:"parent,omitempty"`
|
||||
Due string `json:"due,omitempty"`
|
||||
Wait string `json:"wait,omitempty"`
|
||||
Scheduled string `json:"scheduled,omitempty"`
|
||||
Until string `json:"until,omitempty"`
|
||||
Start string `json:"start,omitempty"`
|
||||
End string `json:"end,omitempty"`
|
||||
Entry string `json:"entry,omitempty"`
|
||||
Modified string `json:"modified,omitempty"`
|
||||
Recur string `json:"recur,omitempty"`
|
||||
Annotations []Annotation `json:"annotations,omitempty"`
|
||||
Id int64 `json:"id,omitempty"`
|
||||
Uuid string `json:"uuid,omitempty"`
|
||||
Description string `json:"description,omitempty"`
|
||||
Project string `json:"project"`
|
||||
Priority string `json:"priority"`
|
||||
Status string `json:"status,omitempty"`
|
||||
Tags []string `json:"tags"`
|
||||
VirtualTags []string `json:"-"`
|
||||
Depends []string `json:"depends,omitempty"`
|
||||
DependsIds string `json:"-"`
|
||||
Urgency float32 `json:"urgency,omitempty"`
|
||||
Parent string `json:"parent,omitempty"`
|
||||
Due string `json:"due,omitempty"`
|
||||
Wait string `json:"wait,omitempty"`
|
||||
Scheduled string `json:"scheduled,omitempty"`
|
||||
Until string `json:"until,omitempty"`
|
||||
Start string `json:"start,omitempty"`
|
||||
End string `json:"end,omitempty"`
|
||||
Entry string `json:"entry,omitempty"`
|
||||
Modified string `json:"modified,omitempty"`
|
||||
Recur string `json:"recur,omitempty"`
|
||||
Annotations []Annotation `json:"annotations,omitempty"`
|
||||
Udas map[string]any `json:"-"`
|
||||
}
|
||||
|
||||
func (t *Task) GetString(fieldWFormat string) string {
|
||||
|
||||
@ -89,6 +89,8 @@ type TaskWarrior interface {
|
||||
GetReport(report string) *Report
|
||||
GetReports() Reports
|
||||
|
||||
GetUdas() []string
|
||||
|
||||
GetTasks(report *Report, filter ...string) Tasks
|
||||
AddTask(task *Task) error
|
||||
ImportTask(task *Task)
|
||||
@ -169,7 +171,15 @@ func (ts *TaskSquire) GetTasks(report *Report, filter ...string) Tasks {
|
||||
return nil
|
||||
}
|
||||
|
||||
for _, task := range tasks {
|
||||
unstructuredTasks := make([]map[string]any, 0)
|
||||
err = json.Unmarshal(output, &unstructuredTasks)
|
||||
if err != nil {
|
||||
slog.Error("Failed unmarshalling tasks:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
for i, task := range tasks {
|
||||
task.Udas = unstructuredTasks[i]
|
||||
if task.Depends != nil && len(task.Depends) > 0 {
|
||||
ids := make([]string, len(task.Depends))
|
||||
for i, dependUuid := range task.Depends {
|
||||
@ -281,10 +291,18 @@ func (ts *TaskSquire) GetTags() []string {
|
||||
}
|
||||
|
||||
tags := make([]string, 0)
|
||||
tagSet := make(map[string]struct{})
|
||||
|
||||
for _, tag := range strings.Split(string(output), "\n") {
|
||||
if _, ok := virtualTags[tag]; !ok && tag != "" {
|
||||
tags = append(tags, tag)
|
||||
tagSet[tag] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
||||
for _, tag := range strings.Split(ts.config.Get("uda.tasksquire.tags.default"), ",") {
|
||||
if _, ok := tagSet[tag]; !ok {
|
||||
tags = append(tags, tag)
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,6 +325,27 @@ func (ts *TaskSquire) GetReports() Reports {
|
||||
return ts.reports
|
||||
}
|
||||
|
||||
func (ts *TaskSquire) GetUdas() []string {
|
||||
ts.mutex.Lock()
|
||||
defer ts.mutex.Unlock()
|
||||
|
||||
cmd := exec.Command(twBinary, append(ts.defaultArgs, "_udas")...)
|
||||
output, err := cmd.CombinedOutput()
|
||||
if err != nil {
|
||||
slog.Error("Failed getting config:", err)
|
||||
return nil
|
||||
}
|
||||
|
||||
udas := make([]string, 0)
|
||||
for _, uda := range strings.Split(string(output), "\n") {
|
||||
if uda != "" {
|
||||
udas = append(udas, uda)
|
||||
}
|
||||
}
|
||||
|
||||
return udas
|
||||
}
|
||||
|
||||
func (ts *TaskSquire) SetContext(context *Context) error {
|
||||
ts.mutex.Lock()
|
||||
defer ts.mutex.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user