iostreams

package
v0.5.2 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2026 License: MIT Imports: 6 Imported by: 0 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

Overview

Package iostreams bundles stdin/stdout/stderr with the terminal facts commands need: whether each stream is a TTY, whether color is on, and the terminal width. Modelled on github.com/cli/cli pkg/iostreams (MIT).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColorScheme added in v0.2.0

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

ColorScheme styles text for one stream. When color is off every method returns its input unchanged, so plain output stays byte-identical.

func (*ColorScheme) Accent added in v0.2.0

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

Accent is for identifiers: issue IDs, command names and flags.

func (*ColorScheme) Bold added in v0.2.0

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

Bold is for headings, summaries and the command to run next.

func (*ColorScheme) Dim added in v0.2.0

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

Dim is for labels and secondary detail.

func (*ColorScheme) Enabled added in v0.2.0

func (c *ColorScheme) Enabled() bool

Enabled reports whether the scheme adds escapes.

func (*ColorScheme) Error added in v0.2.0

func (c *ColorScheme) Error(line string) string

Error renders an error line in red with every `command` in it bold, so the command that unblocks the user stands out.

func (*ColorScheme) Green added in v0.2.0

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

Green marks success and resolved states.

func (*ColorScheme) Priority added in v0.2.0

func (c *ColorScheme) Priority(name string) string

Priority colors a Priority value: critical red, major yellow.

func (*ColorScheme) Red added in v0.2.0

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

Red marks errors and critical priorities.

func (*ColorScheme) State added in v0.2.0

func (c *ColorScheme) State(name string, resolved bool) string

State colors a State value by meaning: resolved states green, open and in-progress states yellow. resolved is the issue's own resolved flag, when known; unknown names are left plain.

func (*ColorScheme) SuccessIcon added in v0.2.0

func (c *ColorScheme) SuccessIcon() string

SuccessIcon is a check mark, green when color is on.

func (*ColorScheme) Yellow added in v0.2.0

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

Yellow marks open and in-progress states.

type IOStreams

type IOStreams struct {
	In     io.Reader
	Out    io.Writer
	ErrOut io.Writer
	// contains filtered or unexported fields
}

IOStreams carries the process streams and their terminal capabilities.

func System

func System() *IOStreams

System returns streams bound to the process's stdin, stdout and stderr.

func Test

func Test() (ios *IOStreams, stdin, stdout, stderr *bytes.Buffer)

Test returns streams backed by buffers, with every TTY flag off.

func (*IOStreams) CanPrompt

func (s *IOStreams) CanPrompt() bool

CanPrompt reports whether interactive prompts are allowed: both stdin and stdout must be terminals, so piped and scripted runs never block on input.

func (*IOStreams) ColorEnabled

func (s *IOStreams) ColorEnabled() bool

func (*IOStreams) ColorScheme added in v0.2.0

func (s *IOStreams) ColorScheme() *ColorScheme

ColorScheme returns the scheme for stdout.

func (*IOStreams) DisableColor added in v0.2.0

func (s *IOStreams) DisableColor()

DisableColor turns color off on every stream (--no-color, --json).

func (*IOStreams) ErrColorEnabled added in v0.2.0

func (s *IOStreams) ErrColorEnabled() bool

ErrColorEnabled reports whether stderr gets color.

func (*IOStreams) ErrColorScheme added in v0.2.0

func (s *IOStreams) ErrColorScheme() *ColorScheme

ErrColorScheme returns the scheme for stderr.

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) SetColorEnabled

func (s *IOStreams) SetColorEnabled(v bool)

func (*IOStreams) SetErrColorEnabled added in v0.2.0

func (s *IOStreams) SetErrColorEnabled(v bool)

SetErrColorEnabled turns stderr color on or off.

func (*IOStreams) SetStderrTTY

func (s *IOStreams) SetStderrTTY(v bool)

func (*IOStreams) SetStdinTTY

func (s *IOStreams) SetStdinTTY(v bool)

func (*IOStreams) SetStdoutTTY

func (s *IOStreams) SetStdoutTTY(v bool)

func (*IOStreams) Symbols

func (s *IOStreams) Symbols() (ok, fail string)

Symbols returns check and cross marks, colored when color is on.

func (*IOStreams) TerminalWidth

func (s *IOStreams) TerminalWidth() int

Jump to

Keyboard shortcuts

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