-
-
Notifications
You must be signed in to change notification settings - Fork 105
/
show.go
51 lines (42 loc) · 1.17 KB
/
show.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
package main
import (
"strings"
"github.com/pkg/browser"
todoist "github.com/sachaos/todoist/lib"
"github.com/urfave/cli/v2"
)
func Show(c *cli.Context) error {
client := GetClient(c)
item_id := c.Args().First()
item := client.Store.FindItem(item_id)
if item == nil {
return IdNotFound
}
colorList := ColorList()
var projectIds []string
for _, project := range client.Store.Projects {
projectIds = append(projectIds, project.GetID())
}
projectColorHash := GenerateColorHash(projectIds, colorList)
records := [][]string{
[]string{"ID", IdFormat(item)},
[]string{"Content", ContentFormat(item)},
[]string{"Project", ProjectFormat(item.ProjectID, client.Store, projectColorHash, c)},
[]string{"Labels", item.LabelsString(client.Store)},
[]string{"Priority", PriorityFormat(item.Priority)},
[]string{"DueDate", DueDateFormat(item.DateTime(), item.AllDay)},
[]string{"URL", strings.Join(todoist.GetContentURL(item), ",")},
}
defer writer.Flush()
for _, record := range records {
writer.Write(record)
}
if todoist.HasURL(item) {
if c.Bool("browse") {
for _, url := range todoist.GetContentURL(item) {
browser.OpenURL(url)
}
}
}
return nil
}