-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #177 from ngageoint/issue176
Closes #176 added red text for stderr output
- Loading branch information
Showing
14 changed files
with
1,923 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
package streampainter | ||
|
||
import ( | ||
"os" | ||
|
||
"github.com/fatih/color" | ||
) | ||
|
||
type StreamPainter struct { | ||
paintColor color.Attribute | ||
} | ||
|
||
/* | ||
* NewStreamPainter returns new streampainter | ||
*/ | ||
func NewStreamPainter(textColor color.Attribute) *StreamPainter { | ||
return &StreamPainter{textColor} | ||
} | ||
|
||
func (w *StreamPainter) Write(p []byte) (int, error) { | ||
n := len(p) | ||
color.New(w.paintColor).Fprintf(os.Stderr, string(p[:n])) | ||
return n, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package streampainter | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/fatih/color" | ||
) | ||
|
||
func TestStreamPainter(t *testing.T) { | ||
writer := NewStreamPainter(color.FgRed) | ||
_, err := writer.Write([]byte("should be in red")) | ||
if err != nil { | ||
t.Errorf("Error should be 'nil', but was %v", err.Error()) | ||
} | ||
if writer.paintColor != color.FgRed { | ||
t.Errorf("Assigned color expected FgRed, but was %v", writer.paintColor) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.