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

@ -60,20 +60,14 @@ func PullDetails(pr *gitea.PullRequest, reviews []*gitea.PullReview) {
// PullsList prints a listing of pulls
func PullsList(prs []*gitea.PullRequest, output string) {
var values [][]string
headers := []string{
t := tableWithHeader(
"Index",
"Title",
"State",
"Author",
"Milestone",
"Updated",
}
if len(prs) == 0 {
outputList(output, headers, values)
return
}
)
for _, pr := range prs {
if pr == nil {
@ -87,18 +81,15 @@ func PullsList(prs []*gitea.PullRequest, output string) {
if pr.Milestone != nil {
mile = pr.Milestone.Title
}
values = append(
values,
[]string{
strconv.FormatInt(pr.Index, 10),
pr.Title,
string(pr.State),
author,
mile,
FormatTime(*pr.Updated),
},
t.addRow(
strconv.FormatInt(pr.Index, 10),
pr.Title,
string(pr.State),
author,
mile,
FormatTime(*pr.Updated),
)
}
outputList(output, headers, values)
t.print(output)
}