iostreams

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Mar 23, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package iostreams provides input/output stream management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CanPromptForInput

func CanPromptForInput() bool

CanPromptForInput returns true if we can prompt for input

func CaptureOutput

func CaptureOutput(f func() error) (stdout, stderr string, err error)

CaptureOutput captures stdout and stderr for testing

func IsInputTTY

func IsInputTTY() bool

IsInputTTY returns true if input is from a terminal

Types

type ColorScheme

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

ColorScheme provides color output utilities

func (*ColorScheme) Blue

func (c *ColorScheme) Blue(text string) string

Blue returns the text in blue

func (*ColorScheme) Bold

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

Bold returns the text in bold

func (*ColorScheme) ColorFromString

func (c *ColorScheme) ColorFromString(colorName string) func(string) string

ColorFromString returns a color function based on a string name

func (*ColorScheme) Cyan

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

Cyan returns the text in cyan

func (*ColorScheme) FailureIcon

func (c *ColorScheme) FailureIcon() string

FailureIcon returns a red X

func (*ColorScheme) Gray

func (c *ColorScheme) Gray(text string) string

Gray returns the text in gray

func (*ColorScheme) Green

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

Green returns the text in green

func (*ColorScheme) Magenta

func (c *ColorScheme) Magenta(text string) string

Magenta returns the text in magenta

func (*ColorScheme) Red

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

Red returns the text in red

func (*ColorScheme) SuccessIcon

func (c *ColorScheme) SuccessIcon() string

SuccessIcon returns a green checkmark

func (*ColorScheme) WarningIcon

func (c *ColorScheme) WarningIcon() string

WarningIcon returns a yellow warning sign

func (*ColorScheme) Yellow

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

Yellow returns the text in yellow

type IOStreams

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

IOStreams holds the standard input, output, and error streams

func System

func System() *IOStreams

System returns IOStreams connected to standard input, output, and error

func Test

func Test() (*IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

Test returns IOStreams suitable for testing

func (*IOStreams) ColorEnabled

func (s *IOStreams) ColorEnabled() bool

ColorEnabled returns true if color output is enabled

func (*IOStreams) ColorScheme

func (s *IOStreams) ColorScheme() *ColorScheme

ColorScheme returns a ColorScheme for output

func (*IOStreams) IsStderrTTY

func (s *IOStreams) IsStderrTTY() bool

IsStderrTTY returns true if stderr is a terminal

func (*IOStreams) IsStdinTTY

func (s *IOStreams) IsStdinTTY() bool

IsStdinTTY returns true if stdin is a terminal

func (*IOStreams) IsStdoutTTY

func (s *IOStreams) IsStdoutTTY() bool

IsStdoutTTY returns true if stdout is a terminal

func (*IOStreams) SetPager

func (s *IOStreams) SetPager(pager string)

SetPager sets the pager command

func (*IOStreams) StartPager

func (s *IOStreams) StartPager() error

StartPager starts a pager for output

func (*IOStreams) StopPager

func (s *IOStreams) StopPager() error

StopPager stops the pager

Source Files

  • color.go
  • iostreams.go

Jump to

Keyboard shortcuts

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