Skip to content

Commit

Permalink
feat(PrintErr): add method for printing to error output
Browse files Browse the repository at this point in the history
  • Loading branch information
b5 committed Mar 14, 2019
1 parent af64259 commit 0c44c82
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions streams.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// Package ioes or "in, out, error streams" provides standard names and utilities
// for working with traditional "stdout" streams
// for working with traditional stdin/stdout/stderr streams.
package ioes

import (
Expand Down Expand Up @@ -55,7 +55,7 @@ func (s IOStreams) Close() error {
return nil
}

// Print writes a msg to the Out stream
// Print writes a msg to the out stream, printing
func (s IOStreams) Print(msg string) {
if s.SpinnerActive() {
s.StopSpinner()
Expand All @@ -64,6 +64,15 @@ func (s IOStreams) Print(msg string) {
s.Out.Write([]byte(msg))
}

// PrintErr writes a msg to the Err stream, printing
func (s IOStreams) PrintErr(msg string) {
if s.SpinnerActive() {
s.StopSpinner()
defer s.StartSpinner()
}
s.ErrOut.Write([]byte(msg))
}

// NewIOStreams creates streams
func NewIOStreams(in io.Reader, out, errOut io.Writer) IOStreams {
sp := spinner.New(spinner.CharSets[24], 100*time.Millisecond)
Expand Down

0 comments on commit 0c44c82

Please sign in to comment.