diff --git a/cmd/util/format.go b/cmd/util/format.go index 51c0db7..638eb27 100644 --- a/cmd/util/format.go +++ b/cmd/util/format.go @@ -6,7 +6,6 @@ import ( "regexp" "sort" "strconv" - "strings" ) func StringWidthWithoutColor(s string) int { @@ -77,10 +76,10 @@ func ItemTableString(items []todoist.Item, relations todoist.ItemRelations, f fu if v, ok := relations.Projects[i.ProjectID]; ok { project = v } - labels := []string{} + var labels todoist.Labels for _, lid := range i.Labels { if v, ok := relations.Labels[lid]; ok { - labels = append(labels, v.String()) + labels = append(labels, v) } } rows = append(rows, []todoist.ColorStringer{ @@ -88,7 +87,7 @@ func ItemTableString(items []todoist.Item, relations todoist.ItemRelations, f fu f(i), todoist.NewNoColorString(strconv.Itoa(i.Priority)), project, - todoist.NewNoColorString(strings.Join(labels, " ")), + labels, todoist.NewNoColorString(i.Content), }) } diff --git a/todoist/label.go b/todoist/label.go index 9f4e91e..414e921 100644 --- a/todoist/label.go +++ b/todoist/label.go @@ -43,6 +43,24 @@ func (l Label) ColorString() string { return color.New(attr).Sprint(l.String()) } +type Labels []Label + +func (ls Labels) String() string { + var arr []string + for _, l := range ls { + arr = append(arr, l.String()) + } + return strings.Join(arr, " ") +} + +func (ls Labels) ColorString() string { + var arr []string + for _, l := range ls { + arr = append(arr, l.ColorString()) + } + return strings.Join(arr, " ") +} + type LabelClient struct { *Client cache *labelCache