-
Notifications
You must be signed in to change notification settings - Fork 14
/
list.go
54 lines (46 loc) · 1.24 KB
/
list.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package alfred
import (
"fmt"
"sort"
)
func list(context *Context, tasks map[string]Task) {
maxLabel := 0
maxSummary := 0
labels := make([]string, 0)
for label, task := range tasks {
// lets add the label to the list(so we an alphabatize the list)
labels = append(labels, label)
// figure out max label size
if len(label) >= maxLabel {
maxLabel = len(label)
}
// figure out max summary size
if len(task.Summary) >= maxSummary {
maxSummary = len(task.Summary)
}
}
// alphabatize the list
sort.Strings(labels)
noLabels := 0
// insignifigant tasks
// still chewing on this one. Not sure if we should include them or not
/*for _, label := range labels {
task := tasks[label]
if task.Summary == "" {
noLabels++
fmt.Print(translate("{{ .Text.Grey }}"+label+"{{ .Text.Reset }}", emptyContext()), "\t")
}
}*/
if noLabels != 0 {
// TODO: we need to determine if we should show this or not
fmt.Println()
}
// signifigant tasks
for _, label := range labels {
task := tasks[label]
if !task.IsPrivate() {
fmt.Print(translate(" {{ .Text.Task }}"+padRight(label, maxLabel, " "), context))
fmt.Println(translate("{{ .Text.Grey }} | {{ .Text.Reset }}"+padRight(task.Summary, maxSummary, " "), context))
}
}
}