ioes

package module
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2020 License: MIT Imports: 7 Imported by: 8

README

ioes

-- import "github.com/qri-io/ioes"

Package ioes or "in, out, error streams" provides standard names and utilities for working with traditional "stdout" streams

Usage

type IOStreams
type IOStreams struct {
	In     io.Reader
	Out    io.Writer
	ErrOut io.Writer
}

IOStreams provides standard names for iostreams and common methods for managing progress indicators & other contextual output. IOStreams is broken out as a sepearate package to facilitate plumbing contextual feedback into the depths of an application architecture, while also providing clear state management for when contextual feedback doesn't work. As an example, IOStreams may be routed over websockets to provide HTTP output, and in this context it's far easier to disable things like spinners outright IOStreams must be created with a "New" method

func NewDiscardIOStreams
func NewDiscardIOStreams() IOStreams

NewDiscardIOStreams returns a valid IOStreams that just discards

func NewIOStreams
func NewIOStreams(in io.Reader, out, errOut io.Writer) IOStreams

NewIOStreams creates streams

func NewStdIOStreams
func NewStdIOStreams() IOStreams

NewStdIOStreams creates a standard set of streams, with in, out, and error mapped to os.Stdin, os.Stdout, and os.Stderr respectively

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

NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests

func (IOStreams) Print
func (s IOStreams) Print(msg string)

Print writes a msg to the Out stream

func (IOStreams) SpinnerActive
func (s IOStreams) SpinnerActive() bool

SpinnerActive returns the active state of the progres spinner

func (IOStreams) SpinnerMsg
func (s IOStreams) SpinnerMsg(msg string)

SpinnerMsg sets the spinner suffix message

func (IOStreams) StartSpinner
func (s IOStreams) StartSpinner()

StartSpinner begins the progress spinner

func (IOStreams) StopSpinner
func (s IOStreams) StopSpinner()

StopSpinner halts the progress spinner

Documentation

Overview

Package ioes or "in, out, error streams" provides standard names and utilities for working with traditional stdin/stdout/stderr streams.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type IOStreams

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

IOStreams provides standard names for iostreams and common methods for managing progress indicators & other contextual output. IOStreams is broken out as a sepearate package to facilitate plumbing contextual feedback into the depths of an application architecture, while also providing clear state management for when contextual feedback doesn't work. As an example, IOStreams may be routed over websockets to provide HTTP output, and in this context it's far easier to disable things like spinners outright IOStreams must be created with a "New" method

func NewDiscardIOStreams

func NewDiscardIOStreams() IOStreams

NewDiscardIOStreams returns a valid IOStreams that just discards

func NewIOStreams

func NewIOStreams(in io.Reader, out, errOut io.Writer) IOStreams

NewIOStreams creates streams

func NewStdIOStreams

func NewStdIOStreams() IOStreams

NewStdIOStreams creates a standard set of streams, with in, out, and error mapped to os.Stdin, os.Stdout, and os.Stderr respectively

func NewTestIOStreams

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

NewTestIOStreams returns a valid IOStreams and in, out, errout buffers for unit tests

func (IOStreams) Close

func (s IOStreams) Close() error

Close checks to see if any/all of in/out/errOut are closable, and if so closes them

func (IOStreams) IsCygwinTerminal added in v0.1.1

func (s IOStreams) IsCygwinTerminal() bool

IsCygwinTerminal returns true when IOStreams Out is a Cygwin file descriptor

func (IOStreams) IsTerminal added in v0.1.1

func (s IOStreams) IsTerminal() bool

IsTerminal returns true when IOStreams Out is a terminal file descriptor

func (IOStreams) Print

func (s IOStreams) Print(msg string)

Print writes a msg to the out stream, printing

func (IOStreams) PrintErr

func (s IOStreams) PrintErr(msg string)

PrintErr writes a msg to the Err stream, printing

func (IOStreams) SpinnerActive

func (s IOStreams) SpinnerActive() bool

SpinnerActive returns the active state of the progres spinner

func (IOStreams) SpinnerMsg

func (s IOStreams) SpinnerMsg(msg string)

SpinnerMsg sets the spinner suffix message

func (IOStreams) StartSpinner

func (s IOStreams) StartSpinner()

StartSpinner begins the progress spinner

func (IOStreams) StopSpinner

func (s IOStreams) StopSpinner()

StopSpinner halts the progress spinner

Jump to

Keyboard shortcuts

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