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 ¶
- type ColorScheme
- func (c *ColorScheme) Accent(s string) string
- func (c *ColorScheme) Bold(s string) string
- func (c *ColorScheme) Dim(s string) string
- func (c *ColorScheme) Enabled() bool
- func (c *ColorScheme) Error(line string) string
- func (c *ColorScheme) Green(s string) string
- func (c *ColorScheme) Priority(name string) string
- func (c *ColorScheme) Red(s string) string
- func (c *ColorScheme) State(name string, resolved bool) string
- func (c *ColorScheme) SuccessIcon() string
- func (c *ColorScheme) Yellow(s string) string
- type IOStreams
- func (s *IOStreams) CanPrompt() bool
- func (s *IOStreams) ColorEnabled() bool
- func (s *IOStreams) ColorScheme() *ColorScheme
- func (s *IOStreams) DisableColor()
- func (s *IOStreams) ErrColorEnabled() bool
- func (s *IOStreams) ErrColorScheme() *ColorScheme
- func (s *IOStreams) IsStderrTTY() bool
- func (s *IOStreams) IsStdinTTY() bool
- func (s *IOStreams) IsStdoutTTY() bool
- func (s *IOStreams) SetColorEnabled(v bool)
- func (s *IOStreams) SetErrColorEnabled(v bool)
- func (s *IOStreams) SetStderrTTY(v bool)
- func (s *IOStreams) SetStdinTTY(v bool)
- func (s *IOStreams) SetStdoutTTY(v bool)
- func (s *IOStreams) Symbols() (ok, fail string)
- func (s *IOStreams) TerminalWidth() int
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 (*IOStreams) CanPrompt ¶
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 (*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
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 (*IOStreams) IsStdinTTY ¶
func (*IOStreams) IsStdoutTTY ¶
func (*IOStreams) SetColorEnabled ¶
func (*IOStreams) SetErrColorEnabled ¶ added in v0.2.0
SetErrColorEnabled turns stderr color on or off.