Documentation
¶
Overview ¶
Package output provides rendering utilities for CLI command output.
Index ¶
- Constants
- Variables
- func AvailableText(available bool) string
- func GreenText(s string) string
- func PrintJSON(w io.Writer, v any) error
- func PrintPlainDetailLines(w io.Writer, lines []DetailLine) error
- func PrintStyledDetailLines(w io.Writer, lines []DetailLine) error
- func PrintStyledTable(w io.Writer, headers []string, rows [][]string) error
- func PrintTable(w io.Writer, headers []string, rows [][]string) error
- func RenderDetail[T any](ios *iostreams.IOStreams, outputFormat string, data T, r DetailRenderer[T]) error
- func RenderList[T any](ios *iostreams.IOStreams, outputFormat string, data T, ...) error
- func ResolveFormat(explicit string) string
- func StatusColor(status string) string
- func YellowText(s string) string
- type DetailLine
- type DetailRenderer
Constants ¶
const ( FormatTable = "table" FormatJSON = "json" )
Variables ¶
var ( HeaderStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color(accentColor)).Padding(0, 1) EvenRowStyle = lipgloss.NewStyle().Padding(0, 1).Foreground(lipgloss.BrightWhite) OddRowStyle = lipgloss.NewStyle().Padding(0, 1).Foreground(lipgloss.Color("245")) BorderStyle = lipgloss.NewStyle().Foreground(lipgloss.Color(accentColor)) LabelStyle = lipgloss.NewStyle().Bold(true).Foreground(lipgloss.Color("245")).Width(14) ValueStyle = lipgloss.NewStyle() )
Style definitions shared across all commands.
Functions ¶
func AvailableText ¶
AvailableText returns a colorized "Yes" or "No" instead of true/false.
func PrintPlainDetailLines ¶
func PrintPlainDetailLines(w io.Writer, lines []DetailLine) error
PrintPlainDetailLines renders detail lines as plain text for piped output.
func PrintStyledDetailLines ¶
func PrintStyledDetailLines(w io.Writer, lines []DetailLine) error
PrintStyledDetailLines renders detail lines with lipgloss styling.
func PrintStyledTable ¶
PrintStyledTable renders a lipgloss table with rounded borders and styled rows.
func PrintTable ¶
PrintTable renders a plain-text table for piped or non-TTY output.
func RenderDetail ¶
func RenderDetail[T any](ios *iostreams.IOStreams, outputFormat string, data T, r DetailRenderer[T]) error
RenderDetail handles the common format-resolution and output logic for detail commands.
func RenderList ¶
func RenderList[T any]( ios *iostreams.IOStreams, outputFormat string, data T, toRows func(isTTY bool) (headers []string, rows [][]string), ) error
RenderList handles the common format-resolution and output logic for list commands. toRows receives the isTTY flag so callers can apply color only when rendering to a terminal.
func ResolveFormat ¶
ResolveFormat returns the explicit format if provided, otherwise defaults to table. Use -o json for JSON output.
func StatusColor ¶
StatusColor returns the status string with color applied based on its value. Recognized values (from KubeRocketCI CRD status field):
- "created" renders green
- "in_progress" renders yellow
- "failed" renders red
Any other value is returned unstyled.
Types ¶
type DetailLine ¶
DetailLine holds one label-value pair for resource detail rendering. When Styled is populated, the styled renderer uses it instead of Value.