render

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 2, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package render provides terminal output helpers: optional ANSI color and simple aligned tables. Color is disabled when color-mode:none is passed or when output is not a terminal.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Plain

func Plain(format string, a ...any) string

Plain is a convenience for fmt.Sprintf used by callers.

Types

type Colors

type Colors struct {
	// contains filtered or unexported fields
}

Colors holds whether ANSI styling is enabled.

func NewColors

func NewColors(colorMode string, isTTY bool) Colors

NewColors decides whether to colorize. colorMode of "none" forces plain output; otherwise color follows isTTY.

func (Colors) Bold

func (c Colors) Bold(s string) string

func (Colors) Cyan

func (c Colors) Cyan(s string) string

func (Colors) Dim

func (c Colors) Dim(s string) string

func (Colors) Green

func (c Colors) Green(s string) string

func (Colors) Red

func (c Colors) Red(s string) string

func (Colors) Yellow

func (c Colors) Yellow(s string) string

type Table

type Table struct {
	// contains filtered or unexported fields
}

Table renders rows of cells into a left-aligned, space-padded table.

func NewTable

func NewTable(header ...string) *Table

NewTable creates a table with the given header.

func (*Table) Add

func (t *Table) Add(cells ...string)

Add appends a row.

func (*Table) String

func (t *Table) String() string

String renders the table. Width is computed from visible (un-styled) length, so callers should add color after layout, or accept minor misalignment when embedding ANSI codes in cells.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL