iostreams

package
v0.0.2-testing Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 9 Imported by: 1 module, 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

Overview

Package iostreams abstracts stdin/stdout/stderr and decides how the CLI should present itself: human (TTY, colors, spinners, prompts) or machine (plain, no interaction).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DetectAgent

func DetectAgent() string

DetectAgent returns the name of the coding agent driving this process, or "". REEARTH_AGENT overrides detection: a false value disables it, a true value enables it, and any other value is used as the agent's name.

func DetectCI

func DetectCI() bool

DetectCI reports whether the process runs on a CI service.

Types

type ColorScheme

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

ColorScheme renders styled text. When disabled, it returns text unchanged (icons are kept so meaning survives NO_COLOR).

func (*ColorScheme) Accent

func (c *ColorScheme) Accent(s string) string

Accent is the single brand color used for emphasis.

func (*ColorScheme) ActiveMark

func (c *ColorScheme) ActiveMark(active bool) string

ActiveMark marks the active item in a list (● / blank).

func (*ColorScheme) Arrow

func (c *ColorScheme) Arrow() string

func (*ColorScheme) Bold

func (c *ColorScheme) Bold(s string) string

func (*ColorScheme) Cyan

func (c *ColorScheme) Cyan(s string) string

func (*ColorScheme) Dim

func (c *ColorScheme) Dim(s string) string

func (*ColorScheme) Enabled

func (c *ColorScheme) Enabled() bool

func (*ColorScheme) FailureIcon

func (c *ColorScheme) FailureIcon() string

func (*ColorScheme) Green

func (c *ColorScheme) Green(s string) string

func (*ColorScheme) Question

func (c *ColorScheme) Question() string

func (*ColorScheme) Red

func (c *ColorScheme) Red(s string) string

func (*ColorScheme) SuccessIcon

func (c *ColorScheme) SuccessIcon() string

func (*ColorScheme) WarningIcon

func (c *ColorScheme) WarningIcon() string

func (*ColorScheme) Yellow

func (c *ColorScheme) Yellow(s string) string

type IOStreams

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

	// Agent is the name of the detected coding agent, or "" if none.
	Agent string
	// CI reports whether we run on a CI service.
	CI bool

	NoInput bool
	Quiet   bool
	// contains filtered or unexported fields
}

func System

func System() *IOStreams

System returns IOStreams bound to the process's standard streams.

func Test

func Test() (s *IOStreams, in *bytes.Buffer, out *bytes.Buffer, errOut *bytes.Buffer)

Test returns IOStreams backed by buffers. All streams are non-TTY.

func (*IOStreams) CanPrompt

func (s *IOStreams) CanPrompt() bool

CanPrompt reports whether it is OK to ask the user for input.

func (*IOStreams) Color

func (s *IOStreams) Color() *ColorScheme

Color returns the color scheme for stdout.

func (*IOStreams) ErrColor

func (s *IOStreams) ErrColor() *ColorScheme

ErrColor returns the color scheme for stderr.

func (*IOStreams) Hint

func (s *IOStreams) Hint(format string, args ...any)

Hint prints a dimmed secondary line to stderr, aligned under the previous message.

func (*IOStreams) Info

func (s *IOStreams) Info(format string, args ...any)

Info prints "→ message" to stderr.

func (*IOStreams) IsInteractive

func (s *IOStreams) IsInteractive() bool

IsInteractive reports whether a human is likely watching stderr. Spinners, hints and update notices are shown only in this case.

func (*IOStreams) IsStderrTTY

func (s *IOStreams) IsStderrTTY() bool

func (*IOStreams) IsStdinTTY

func (s *IOStreams) IsStdinTTY() bool

func (*IOStreams) IsStdoutTTY

func (s *IOStreams) IsStdoutTTY() bool

func (*IOStreams) Newline

func (s *IOStreams) Newline()

Newline prints an empty line to stderr on a TTY (for visual rhythm only).

func (*IOStreams) Println

func (s *IOStreams) Println(a ...any)

Println prints a plain line to stderr with the standard margin.

func (*IOStreams) SetColorEnabled

func (s *IOStreams) SetColorEnabled(v bool)

SetColorEnabled forces colors on or off for both stdout and stderr.

func (*IOStreams) SetTTY

func (s *IOStreams) SetTTY(stdin, stdout, stderr bool)

SetTTY overrides TTY detection (for tests).

func (*IOStreams) StartProgress

func (s *IOStreams) StartProgress(label string)

StartProgress shows a spinner on stderr. It is a no-op when not interactive.

func (*IOStreams) StopProgress

func (s *IOStreams) StopProgress()

StopProgress removes the spinner if shown.

func (*IOStreams) Success

func (s *IOStreams) Success(format string, args ...any)

Success prints "✓ message" to stderr.

func (*IOStreams) TerminalWidth

func (s *IOStreams) TerminalWidth() int

TerminalWidth returns the width of stdout, or 80 if unknown.

func (*IOStreams) Warn

func (s *IOStreams) Warn(format string, args ...any)

Warn prints "! message" to stderr. Warnings are printed even with --quiet.

Jump to

Keyboard shortcuts

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