File tree Expand file tree Collapse file tree 4 files changed +50
-2
lines changed Expand file tree Collapse file tree 4 files changed +50
-2
lines changed Original file line number Diff line number Diff line change @@ -64,9 +64,18 @@ type UI interface {
64
64
// Table creates a table with the given headers
65
65
Table (headers []string ) Table
66
66
67
- // Writer returns writer of the terminal UI
67
+ // Writer returns the output writer of the terminal UI
68
68
Writer () io.Writer
69
69
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
+
70
79
// Enable or disable quiet mode. Contents passed to Verbose(), Warn(), OK() will be ignored if under quiet mode.
71
80
SetQuiet (bool )
72
81
@@ -217,6 +226,18 @@ func (ui *terminalUI) Writer() io.Writer {
217
226
return ui .Out
218
227
}
219
228
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
+
220
241
func (ui * terminalUI ) SetQuiet (quiet bool ) {
221
242
ui .quiet = quiet
222
243
}
Original file line number Diff line number Diff line change 1
1
module github.com/IBM-Cloud/ibm-cloud-cli-sdk
2
2
3
- go 1.22.12
3
+ go 1.23.0
4
+
5
+ toolchain go1.23.6
4
6
5
7
require (
6
8
github.com/fatih/color v1.7.1-0.20180516100307-2d684516a886
Original file line number Diff line number Diff line change @@ -111,6 +111,12 @@ func (c Command) NameAndAliases() []string {
111
111
// Method is used when defining the Flags in command metadata. @see Plugin#GetMetadata() for use case
112
112
func ConvertCobraFlagsToPluginFlags (cmd * cobra.Command ) []Flag {
113
113
var flags []Flag
114
+ // NOTE: there is a strange behavior in Cobra where you need to call
115
+ // either `InheritedFlags` or `LocalFlags` in order to include global
116
+ // flags when calling `VisitAll`
117
+ // see https://github.com/spf13/cobra/issues/412
118
+ cmd .InheritedFlags ()
119
+
114
120
cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
115
121
var name string
116
122
if f .Shorthand != "" {
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ type FakeUI struct {
27
27
PasswordPrompts []string
28
28
ChoicesPrompts []choicesPrompt
29
29
WarnOutputs []string
30
+ stdoutWriter io.Writer
31
+ stdErrWriter io.Writer
32
+ stdInWriter io.Reader
30
33
31
34
inputs bytes.Buffer
32
35
stdOut bytes.Buffer
@@ -221,6 +224,22 @@ func (ui *FakeUI) Writer() io.Writer {
221
224
return & ui .stdOut
222
225
}
223
226
227
+ func (ui * FakeUI ) ErrWriter () io.Writer {
228
+ return & ui .stdErr
229
+ }
230
+
231
+ // NOTE: SetErrWriter is added here since the method is part of the UI type Interface interface
232
+ // the method is not needed for testing
233
+ func (ui * FakeUI ) SetErrWriter (buf io.Writer ) {
234
+ panic ("unimplemented" )
235
+ }
236
+
237
+ // NOTE: SetErrWriter is added here since the method is part of the UI type Interface interface
238
+ // the method is not needed for testing
239
+ func (ui * FakeUI ) SetWriter (buf io.Writer ) {
240
+ panic ("unimplemented" )
241
+ }
242
+
224
243
func (ui * FakeUI ) SetQuiet (quiet bool ) {
225
244
ui .quiet = quiet
226
245
}
You can’t perform that action at this time.
0 commit comments