MCPcopy
hub / github.com/cli/cli / printLabels

Function printLabels

pkg/cmd/label/list.go:135–153  ·  view source on GitHub ↗
(io *iostreams.IOStreams, labels []label)

Source from the content-addressed store, hash-verified

133}
134
135func printLabels(io *iostreams.IOStreams, labels []label) error {
136 cs := io.ColorScheme()
137 table := tableprinter.New(io, tableprinter.WithHeader("NAME", "DESCRIPTION", "COLOR"))
138
139 for _, label := range labels {
140 // Colorize the label using tableprinter's WithColor function for it to handle non-TTY situations
141 labelColor := tableprinter.WithColor(func(s string) string {
142 return cs.Label(label.Color, s)
143 })
144
145 table.AddField(label.Name, labelColor)
146 table.AddField(label.Description)
147 table.AddField("#" + label.Color)
148
149 table.EndRow()
150 }
151
152 return table.Render()
153}
154
155func listHeader(repoName string, count int, totalCount int) string {
156 return fmt.Sprintf("Showing %d of %s in %s", count, text.Pluralize(totalCount, "label"), repoName)

Callers 1

listRunFunction · 0.85

Calls 5

NewFunction · 0.92
WithHeaderFunction · 0.92
ColorSchemeMethod · 0.80
RenderMethod · 0.65
LabelMethod · 0.45

Tested by

no test coverage detected