mirror of
https://gitea.com/gitea/tea.git
synced 2025-09-02 18:08:30 +02:00
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:
@ -14,33 +14,24 @@ import (
|
||||
|
||||
// LabelsList prints a listing of labels
|
||||
func LabelsList(labels []*gitea.Label, output string) {
|
||||
var values [][]string
|
||||
headers := []string{
|
||||
t := tableWithHeader(
|
||||
"Index",
|
||||
"Color",
|
||||
"Name",
|
||||
"Description",
|
||||
}
|
||||
|
||||
if len(labels) == 0 {
|
||||
outputList(output, headers, values)
|
||||
return
|
||||
}
|
||||
)
|
||||
|
||||
p := termenv.ColorProfile()
|
||||
|
||||
for _, label := range labels {
|
||||
color := termenv.String(label.Color)
|
||||
|
||||
values = append(
|
||||
values,
|
||||
[]string{
|
||||
strconv.FormatInt(label.ID, 10),
|
||||
fmt.Sprint(color.Background(p.Color("#" + label.Color))),
|
||||
label.Name,
|
||||
label.Description,
|
||||
},
|
||||
t.addRow(
|
||||
strconv.FormatInt(label.ID, 10),
|
||||
fmt.Sprint(color.Background(p.Color("#"+label.Color))),
|
||||
label.Name,
|
||||
label.Description,
|
||||
)
|
||||
}
|
||||
outputList(output, headers, values)
|
||||
t.print(output)
|
||||
}
|
||||
|
Reference in New Issue
Block a user