mirror of
https://gitea.com/gitea/tea.git
synced 2026-06-25 22:27:39 +02:00
88f5cdcafa
Fix https://gitea.com/gitea/tea/issues/634, https://gitea.com/gitea/tea/issues/669 Reviewed-on: https://gitea.com/gitea/tea/pulls/1017 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: Minjie Fang <wingsallen@gmail.com> Co-committed-by: Minjie Fang <wingsallen@gmail.com>
38 lines
677 B
Go
38 lines
677 B
Go
// Copyright 2020 The Gitea Authors. All rights reserved.
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
package print
|
|
|
|
import (
|
|
"strconv"
|
|
"strings"
|
|
|
|
gitea "gitea.dev/sdk"
|
|
)
|
|
|
|
// LabelsList prints a listing of labels
|
|
func LabelsList(labels []*gitea.Label, output string) error {
|
|
t := tableWithHeader(
|
|
"Index",
|
|
"Color",
|
|
"Name",
|
|
"Description",
|
|
"Level",
|
|
)
|
|
|
|
for _, label := range labels {
|
|
level := "Repository"
|
|
if strings.Contains(label.URL, "/orgs/") {
|
|
level = "Organization"
|
|
}
|
|
t.addRow(
|
|
strconv.FormatInt(label.ID, 10),
|
|
formatLabel(label, !isMachineReadable(output), label.Color),
|
|
label.Name,
|
|
label.Description,
|
|
level,
|
|
)
|
|
}
|
|
return t.print(output)
|
|
}
|