iostreams

package
v1.135.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IOStreams

type IOStreams struct {
	In     io.ReadCloser
	Out    io.Writer
	ErrOut io.Writer

	IsStdoutTTY func() bool
	IsStderrTTY func() bool
	// contains filtered or unexported fields
}

func System

func System() *IOStreams

func Test

func Test() *IOStreams

func TestTTY

func TestTTY() *IOStreams

func (*IOStreams) ColorEnabled

func (s *IOStreams) ColorEnabled() bool

ColorEnabled reports whether color output should be emitted.

func (*IOStreams) ColorGreen added in v1.9.0

func (s *IOStreams) ColorGreen(str string) string

func (*IOStreams) ColorMagenta added in v1.9.0

func (s *IOStreams) ColorMagenta(str string) string

func (*IOStreams) ColorRed added in v1.9.0

func (s *IOStreams) ColorRed(str string) string

func (*IOStreams) ColorYellow added in v1.17.0

func (s *IOStreams) ColorYellow(str string) string

ColorYellow renders in-progress / pending states. Distinct from green (terminal success) and red (terminal failure) so a glance at the table tells you whether a row is actively running, done, or broken.

func (*IOStreams) SetColorEnabled added in v1.17.0

func (s *IOStreams) SetColorEnabled(v bool)

SetColorEnabled overrides the color decision. The constructor seeds colorEnabled from TTY + NO_COLOR; SetColorEnabled lets a higher layer (e.g. a --no-color persistent flag in root) flip it off after construction. Pass true to force-enable color even on non-TTY (rarely useful — most callers only use this to force-disable).

func (*IOStreams) StartPager

func (s *IOStreams) StartPager() error

StartPager spawns $PAGER (default "less -FRX") and wires IOStreams.Out to the pager's stdin. Only activates when stdout is a TTY; no-op otherwise. Callers must defer StopPager() immediately after a successful call.

func (*IOStreams) StopPager

func (s *IOStreams) StopPager()

StopPager closes the pager's stdin and waits for the process to exit. Safe to call even when no pager was started.

Jump to

Keyboard shortcuts

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