Skip to content

Commit 70ea50e

Browse files
authored
feat: added setter for writers (#445)
* feat: added SetWriter method to term ui * feat: added SetErrWriter method to term ui * feat: added ErrWriter method to return err output * chore: fixed spelling/grammar
1 parent 5247123 commit 70ea50e

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

bluemix/terminal/ui.go

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,18 @@ type UI interface {
6464
// Table creates a table with the given headers
6565
Table(headers []string) Table
6666

67-
// Writer returns writer of the terminal UI
67+
// Writer returns the output writer of the terminal UI
6868
Writer() io.Writer
6969

70+
// SetWriter sets the writer of the terminal UI
71+
SetWriter(buf io.Writer)
72+
73+
// ErrWriter returns the error writer of the terminal UI
74+
ErrWriter() io.Writer
75+
76+
// SetErrWriter sets the error writer of the terminal UI
77+
SetErrWriter(buf io.Writer)
78+
7079
// Enable or disable quiet mode. Contents passed to Verbose(), Warn(), OK() will be ignored if under quiet mode.
7180
SetQuiet(bool)
7281

@@ -217,6 +226,18 @@ func (ui *terminalUI) Writer() io.Writer {
217226
return ui.Out
218227
}
219228

229+
func (ui *terminalUI) ErrWriter() io.Writer {
230+
return ui.ErrOut
231+
}
232+
233+
func (ui *terminalUI) SetWriter(buf io.Writer) {
234+
ui.Out = buf
235+
}
236+
237+
func (ui *terminalUI) SetErrWriter(buf io.Writer) {
238+
ui.ErrOut = buf
239+
}
240+
220241
func (ui *terminalUI) SetQuiet(quiet bool) {
221242
ui.quiet = quiet
222243
}

go.mod

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
module github.com/IBM-Cloud/ibm-cloud-cli-sdk
22

3-
go 1.22.12
3+
go 1.23.0
4+
5+
toolchain go1.23.6
46

57
require (
68
github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886

0 commit comments

Comments
 (0)