console

package
v2.55.0 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2026 License: MIT Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const DefaultSampleSize = 5

DefaultSampleSize maximum number of rows sampled when resolving table columns

View Source
const DefaultTableFlushTimeout = 500 * time.Millisecond

DefaultTableFlushTimeout maximum time the first table rows are buffered while waiting for more rows to be sampled, so long-running streams (e.g. realtime subscriptions) are not delayed indefinitely

Variables

This section is empty.

Functions

This section is empty.

Types

type Console

type Console struct {
	Colorized   bool
	Compact     bool
	Disabled    bool
	Format      config.OutputFormat
	TableViewer *tableviewer.TableView
	// contains filtered or unexported fields
}

Console thread safe way to write to an output

func NewConsole

func NewConsole(w io.Writer, tableOptions *TableOptions, header func([]string) []byte) *Console

NewConsole create a new console writer

func (*Console) Flush added in v2.55.0

func (c *Console) Flush()

Flush render any buffered table output. It should be called once no more output is expected (e.g. at the end of a command)

func (*Console) IsCSV

func (c *Console) IsCSV() bool

IsCSV return true if csv output is set

func (*Console) IsJSON

func (c *Console) IsJSON() bool

IsJSON return true if JSON output is set

func (*Console) IsJSONStream

func (c *Console) IsJSONStream() bool

IsJSONStream check if json stream mode is activated

func (*Console) IsTable

func (c *Console) IsTable() bool

IsTable return true if table output is set

func (*Console) IsTextOutput added in v2.30.0

func (c *Console) IsTextOutput() bool

func (*Console) Printf

func (c *Console) Printf(format string, a ...interface{}) (int, error)

Printf mimics fmt.Printf

func (*Console) Println

func (c *Console) Println(a ...interface{}) (int, error)

Println mimics fmt.Println

func (*Console) SetHeaderFromInput

func (c *Console) SetHeaderFromInput(input string, groups []jsonfilter.KeyGroup)

func (*Console) SetOut added in v2.52.2

func (c *Console) SetOut(w io.Writer)

func (*Console) WithCSVHeader

func (c *Console) WithCSVHeader() bool

WithCSVHeader returns true if the csv output should include a header

func (*Console) Write

func (c *Console) Write(b []byte) (n int, err error)

Write a line to the output. Supports concurrent access

type TableOptions

type TableOptions struct {
	// MinColumnWidth minimum column width
	MinColumnWidth int

	// MinEmptyValueColumnWidth minimum column width to use when the value is empty
	// If set to 0, then the MinColumnWidth will be used
	MinEmptyValueColumnWidth int

	// MaxColumnWidth maximum column width
	MaxColumnWidth int

	// ColumnPadding column padding
	ColumnPadding int

	// Row mode (truncate or wrap)
	RowMode string

	// NumberFormatter formatting used when rendering numbers
	NumberFormatter numbers.NumberFormatter

	// SampleSize maximum number of rows which are sampled when resolving
	// the table columns and column widths. If set to 0, then a default value will be used
	SampleSize int

	// SampleTimeout maximum duration to buffer rows whilst waiting for more rows
	// to be sampled, so that streamed output is not delayed indefinitely.
	// If set to 0, then buffered rows are only rendered once the sample size is
	// reached or no more output is expected
	SampleTimeout time.Duration
}

TableOptions table options to control the column behaviour

Jump to

Keyboard shortcuts

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