iostreams

package
v1.42.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var IsTerminal = func(f *os.File) bool {
	return isatty.IsTerminal(f.Fd()) || IsCygwinTerminal(f)
}

IsTerminal reports whether the file descriptor is connected to a terminal

View Source
var TerminalSize = func(w interface{}) (int, int, error) {
	if f, isFile := w.(*os.File); isFile {
		return term.GetSize(int(f.Fd()))
	}

	return 0, 0, fmt.Errorf("%v is not a file", w)
}

Functions

func Is256ColorSupported

func Is256ColorSupported() bool

func IsCygwinTerminal

func IsCygwinTerminal(f *os.File) bool

func NewColorable

func NewColorable(out io.Writer) io.Writer

NewColorable returns an output stream that handles ANSI color sequences on Windows

func TerminalWidth

func TerminalWidth(out io.Writer) int

Types

type ColorPalette

type ColorPalette struct {
	// Magenta outputs ANSI color if stdout is a tty
	Magenta func(string) string
	// Cyan outputs ANSI color if stdout is a tty
	Cyan func(string) string
	// Red outputs ANSI color if stdout is a tty
	Red func(string) string
	// Yellow outputs ANSI color if stdout is a tty
	Yellow func(string) string
	// Blue outputs ANSI color if stdout is a tty
	Blue func(string) string
	// Green outputs ANSI color if stdout is a tty
	Green func(string) string
	// Gray outputs ANSI color if stdout is a tty
	Gray func(string) string
	// Bold outputs ANSI color if stdout is a tty
	Bold func(string) string
}

func (*ColorPalette) DotWarnIcon

func (c *ColorPalette) DotWarnIcon() string

func (*ColorPalette) FailedIcon

func (c *ColorPalette) FailedIcon() string

func (*ColorPalette) GreenCheck

func (c *ColorPalette) GreenCheck() string

func (*ColorPalette) ProgressIcon

func (c *ColorPalette) ProgressIcon() string

func (*ColorPalette) RedCheck

func (c *ColorPalette) RedCheck() string

func (*ColorPalette) WarnIcon

func (c *ColorPalette) WarnIcon() string

type IOStreams

type IOStreams struct {
	In     io.ReadCloser
	StdOut io.Writer
	StdErr io.Writer

	IsaTTY   bool // stdout is a tty
	IsErrTTY bool // stderr is a tty
	IsInTTY  bool // stdin is a tty
	// contains filtered or unexported fields
}

func Init

func Init() *IOStreams

func Test

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

func (*IOStreams) BackgroundColor

func (s *IOStreams) BackgroundColor() string

func (*IOStreams) Color

func (s *IOStreams) Color() *ColorPalette

func (*IOStreams) ColorEnabled

func (s *IOStreams) ColorEnabled() bool
func (s *IOStreams) Hyperlink(displayText, targetURL string) string

func (*IOStreams) Is256ColorSupported

func (s *IOStreams) Is256ColorSupported() bool

func (*IOStreams) IsInputTTY added in v1.33.0

func (s *IOStreams) IsInputTTY() bool

func (*IOStreams) IsOutputTTY

func (s *IOStreams) IsOutputTTY() bool

IsOutputTTY returns true if both stdout and stderr is TTY

func (*IOStreams) Log

func (s *IOStreams) Log(msg ...interface{})

Log prints output to StdErr

func (*IOStreams) LogInfo

func (s *IOStreams) LogInfo(a ...interface{})

LogInfo is just like Log but prints output to StdOut

func (*IOStreams) LogInfof

func (s *IOStreams) LogInfof(format string, a ...interface{})

LogInfof formats according to a format specifier and writes to StdOut

func (*IOStreams) Logf

func (s *IOStreams) Logf(format string, a ...interface{})

Logf formats according to a format specifier and writes to StdErr

func (*IOStreams) PromptEnabled

func (s *IOStreams) PromptEnabled() bool

func (*IOStreams) ResolveBackgroundColor

func (s *IOStreams) ResolveBackgroundColor(style string) string
func (s *IOStreams) SetDisplayHyperlinks(displayHyperlinks string)

func (*IOStreams) SetPager

func (s *IOStreams) SetPager(cmd string)

func (*IOStreams) SetPrompt

func (s *IOStreams) SetPrompt(promptDisabled string)

func (*IOStreams) StartPager

func (s *IOStreams) StartPager() error

func (*IOStreams) StartSpinner

func (s *IOStreams) StartSpinner(format string, a ...interface{})

func (*IOStreams) StopPager

func (s *IOStreams) StopPager()

func (*IOStreams) StopSpinner

func (s *IOStreams) StopSpinner(format string, a ...interface{})

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