diff --git a/cmd/client.go b/cmd/client.go index 3cd6f25..995251f 100644 --- a/cmd/client.go +++ b/cmd/client.go @@ -8,10 +8,11 @@ import ( ) type issueInfo struct { - Title string - URL string - State string - Labels []interface{} + Title string + URL string + State string + Labels []interface{} + UpdatedAt string } func getIssues(query url.Values) []issueInfo { @@ -33,10 +34,11 @@ func getIssues(query url.Values) []issueInfo { for _, item := range itemsResults { if item.(map[string]interface{})["pull_request"] == nil { issues = append(issues, issueInfo{ - Title: item.(map[string]interface{})["title"].(string), - URL: item.(map[string]interface{})["html_url"].(string), - State: item.(map[string]interface{})["state"].(string), - Labels: item.(map[string]interface{})["labels"].([]interface{}), + Title: item.(map[string]interface{})["title"].(string), + URL: item.(map[string]interface{})["html_url"].(string), + State: item.(map[string]interface{})["state"].(string), + Labels: item.(map[string]interface{})["labels"].([]interface{}), + UpdatedAt: item.(map[string]interface{})["updated_at"].(string), }) } } diff --git a/cmd/ui.go b/cmd/ui.go index 5abaab2..64e0574 100644 --- a/cmd/ui.go +++ b/cmd/ui.go @@ -5,6 +5,7 @@ import ( "net/url" "os" "strings" + "time" "github.com/jedib0t/go-pretty/v6/table" "github.com/jedib0t/go-pretty/v6/text" @@ -139,6 +140,11 @@ func getTemplate(colour string) *promptui.SelectTemplates { return urlSlice[3] + "/" + urlSlice[4] } + funcMap["parseTimestamp"] = func(UpdatedAt string) string { + t, _ := time.Parse("2006-01-02T15:04:05Z", UpdatedAt) + return t.Format("2006-01-02 15:04:05") + } + return &promptui.SelectTemplates{ Active: fmt.Sprintf("\U0001F449 {{ .Title | %s | bold }} {{ .State | faint }}", colour), Inactive: fmt.Sprintf(" {{ .Title | %s }}", colour), @@ -147,6 +153,7 @@ func getTemplate(colour string) *promptui.SelectTemplates { {{ "Repository:" | faint }} {{ .URL | getRepoName }} {{ "Url address:" | faint }} {{ .URL }} {{ "Labels:" | faint }} {{ .Labels | parseLabels }} + {{ "Last updated:" | faint }} {{ .UpdatedAt | parseTimestamp }} `, }