Improved list output (#281)

remove unused debug var

move outputList into a struct

so we can add additional functionality for all list output

rename list output to table.go

make table sortable

sort milestones

sort milestones descending

remove unnecessary if

Co-authored-by: Norwin Roosen <git@nroo.de>
Reviewed-on: https://gitea.com/gitea/tea/pulls/281
Reviewed-by: khmarbaise <khmarbaise@noreply.gitea.io>
Reviewed-by: 6543 <6543@obermui.de>
Co-Authored-By: Norwin <noerw@noreply.gitea.io>
Co-Committed-By: Norwin <noerw@noreply.gitea.io>
This commit is contained in:
Norwin
2020-12-10 06:04:36 +08:00
committed by 6543
parent 4a11cf455f
commit a91168fd36
11 changed files with 141 additions and 170 deletions

View File

@ -12,7 +12,6 @@ import (
// NotificationsList prints a listing of notification threads
func NotificationsList(news []*gitea.NotificationThread, output string, showRepository bool) {
var values [][]string
headers := []string{
"Type",
"Index",
@ -22,6 +21,8 @@ func NotificationsList(news []*gitea.NotificationThread, output string, showRepo
headers = append(headers, "Repository")
}
t := table{headers: headers}
for _, n := range news {
if n.Subject == nil {
continue
@ -41,11 +42,10 @@ func NotificationsList(news []*gitea.NotificationThread, output string, showRepo
if showRepository {
item = append(item, n.Repository.FullName)
}
values = append(values, item)
t.addRowSlice(item)
}
if len(values) != 0 {
outputList(output, headers, values)
if t.Len() != 0 {
t.print(output)
}
return
}