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 ¶
- func DetectAgent() string
- func DetectCI() bool
- type ColorScheme
- func (c *ColorScheme) Accent(s string) string
- func (c *ColorScheme) ActiveMark(active bool) string
- func (c *ColorScheme) Arrow() string
- func (c *ColorScheme) Bold(s string) string
- func (c *ColorScheme) Cyan(s string) string
- func (c *ColorScheme) Dim(s string) string
- func (c *ColorScheme) Enabled() bool
- func (c *ColorScheme) FailureIcon() string
- func (c *ColorScheme) Green(s string) string
- func (c *ColorScheme) Question() string
- func (c *ColorScheme) Red(s string) string
- func (c *ColorScheme) SuccessIcon() string
- func (c *ColorScheme) WarningIcon() string
- func (c *ColorScheme) Yellow(s string) string
- type IOStreams
- func (s *IOStreams) CanPrompt() bool
- func (s *IOStreams) Color() *ColorScheme
- func (s *IOStreams) ErrColor() *ColorScheme
- func (s *IOStreams) Hint(format string, args ...any)
- func (s *IOStreams) Info(format string, args ...any)
- func (s *IOStreams) IsInteractive() bool
- func (s *IOStreams) IsStderrTTY() bool
- func (s *IOStreams) IsStdinTTY() bool
- func (s *IOStreams) IsStdoutTTY() bool
- func (s *IOStreams) Newline()
- func (s *IOStreams) Println(a ...any)
- func (s *IOStreams) SetColorEnabled(v bool)
- func (s *IOStreams) SetTTY(stdin, stdout, stderr bool)
- func (s *IOStreams) StartProgress(label string)
- func (s *IOStreams) StopProgress()
- func (s *IOStreams) Success(format string, args ...any)
- func (s *IOStreams) TerminalWidth() int
- func (s *IOStreams) Warn(format string, args ...any)
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.
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 (*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 ¶
Hint prints a dimmed secondary line to stderr, aligned under the previous message.
func (*IOStreams) IsInteractive ¶
IsInteractive reports whether a human is likely watching stderr. Spinners, hints and update notices are shown only in this case.
func (*IOStreams) IsStderrTTY ¶
func (*IOStreams) IsStdinTTY ¶
func (*IOStreams) IsStdoutTTY ¶
func (*IOStreams) Newline ¶
func (s *IOStreams) Newline()
Newline prints an empty line to stderr on a TTY (for visual rhythm only).
func (*IOStreams) SetColorEnabled ¶
SetColorEnabled forces colors on or off for both stdout and stderr.
func (*IOStreams) StartProgress ¶
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) TerminalWidth ¶
TerminalWidth returns the width of stdout, or 80 if unknown.