outfmt

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Reset   = "\033[0m"
	Bold    = "\033[1m"
	Red     = "\033[31m"
	Green   = "\033[32m"
	Yellow  = "\033[33m"
	Blue    = "\033[34m"
	Magenta = "\033[35m"
	Cyan    = "\033[36m"
	Gray    = "\033[90m"
)

ANSI color codes

Variables

This section is empty.

Functions

func Colorize

func Colorize(text, color string, enabled bool) string

Colorize wraps text in ANSI color codes if colors are enabled

func GetColor

func GetColor(ctx context.Context) string

func GetFormat

func GetFormat(ctx context.Context) string

func GetQuery

func GetQuery(ctx context.Context) string

func GetTemplate added in v0.1.7

func GetTemplate(ctx context.Context) string

func OutputTo added in v0.1.7

func OutputTo(ctx context.Context, w io.Writer, data any, textFn func(io.Writer)) error

func OutputWithQueryTemplateTo added in v0.1.7

func OutputWithQueryTemplateTo(format, query, tmpl string, w io.Writer, data any, textFn func(io.Writer)) error

func OutputWithQueryTo added in v0.1.7

func OutputWithQueryTo(format, query string, w io.Writer, data any, textFn func(io.Writer)) error

func ShouldColorizeWriter added in v0.1.7

func ShouldColorizeWriter(w io.Writer, mode string) bool

ShouldColorizeWriter returns true if output should be colorized for the writer.

func WithColor

func WithColor(ctx context.Context, mode string) context.Context

func WithFormat

func WithFormat(ctx context.Context, format string) context.Context

func WithQuery

func WithQuery(ctx context.Context, query string) context.Context

func WithTemplate added in v0.1.7

func WithTemplate(ctx context.Context, tmpl string) context.Context

func WriteJSON

func WriteJSON(w io.Writer, data any) error

func WriteJSONLines added in v0.1.7

func WriteJSONLines(w io.Writer, data any, query string) error

func WriteJSONPretty

func WriteJSONPretty(w io.Writer, data any) error

func WriteJSONWithQuery

func WriteJSONWithQuery(w io.Writer, data any, queryStr string) error

func WriteTemplate added in v0.1.7

func WriteTemplate(w io.Writer, data any, tmplText string) error

Types

type ColorMode

type ColorMode string

ColorMode represents color output setting

const (
	ColorAuto   ColorMode = "auto"
	ColorAlways ColorMode = "always"
	ColorNever  ColorMode = "never"
)

type TableWriter

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

func NewTable added in v0.1.7

func NewTable(w io.Writer, headers []string, colorEnabled bool) *TableWriter

NewTable creates a TableWriter with optional colorized headers.

func NewTableWriter

func NewTableWriter(w io.Writer) *TableWriter

func (*TableWriter) Append

func (t *TableWriter) Append(row []string)

func (*TableWriter) Render

func (t *TableWriter) Render()

func (*TableWriter) SetHeader

func (t *TableWriter) SetHeader(headers []string)

Jump to

Keyboard shortcuts

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