iostreams

package
v0.0.0-...-873d3b2 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2026 License: MIT Imports: 4 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
	// contains filtered or unexported fields
}

IOStreams collects input and output streams for command execution.

The structure mirrors gh/jk ergonomics by exposing terminal metadata and lazy colour profile detection. Commands can inspect the terminal capabilities to decide when to render ANSI colours, tables, or spinner widgets.

func System

func System() *IOStreams

System returns IOStreams bound to the current process standard streams and captures terminal metadata so downstream components can make ergonomic decisions (colours, paging, prompts, etc.).

func (*IOStreams) CanPrompt

func (s *IOStreams) CanPrompt() bool

CanPrompt reports whether stdin is a TTY and therefore suitable for interactive prompts.

func (*IOStreams) ClearScreen

func (s *IOStreams) ClearScreen()

ClearScreen clears the screen and moves cursor to top-left. Useful for refreshing watch mode output. No-op if not a TTY.

func (*IOStreams) ColorEnabled

func (s *IOStreams) ColorEnabled() bool

ColorEnabled returns true when ANSI colour output should be rendered. The decision is cached so repeated checks are inexpensive.

func (*IOStreams) IsStderrTTY

func (s *IOStreams) IsStderrTTY() bool

IsStderrTTY reports whether stderr is attached to a terminal.

func (*IOStreams) IsStdoutTTY

func (s *IOStreams) IsStdoutTTY() bool

IsStdoutTTY reports whether stdout is attached to a terminal.

func (*IOStreams) SetColorEnabled

func (s *IOStreams) SetColorEnabled(enabled bool)

SetColorEnabled allows callers (e.g. tests) to force colour behaviour.

func (*IOStreams) StartAlternateScreenBuffer

func (s *IOStreams) StartAlternateScreenBuffer()

StartAlternateScreenBuffer switches to the alternate screen buffer. This keeps the terminal clean during watch mode, showing only the final result on the original screen when done. No-op if not a TTY.

func (*IOStreams) StopAlternateScreenBuffer

func (s *IOStreams) StopAlternateScreenBuffer()

StopAlternateScreenBuffer switches back to the main screen buffer. No-op if not a TTY.

Jump to

Keyboard shortcuts

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