Giter VIP home page Giter VIP logo

ioes's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.