File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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+
220241func (ui * terminalUI ) SetQuiet (quiet bool ) {
221242 ui .quiet = quiet
222243}
Original file line number Diff line number Diff line change 11module 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
57require (
68 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 {
111111// Method is used when defining the Flags in command metadata. @see Plugin#GetMetadata() for use case
112112func ConvertCobraFlagsToPluginFlags (cmd * cobra.Command ) []Flag {
113113 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+
114120 cmd .Flags ().VisitAll (func (f * pflag.Flag ) {
115121 var name string
116122 if f .Shorthand != "" {
Original file line number Diff line number Diff line change @@ -27,6 +27,9 @@ type FakeUI struct {
2727 PasswordPrompts []string
2828 ChoicesPrompts []choicesPrompt
2929 WarnOutputs []string
30+ stdoutWriter io.Writer
31+ stdErrWriter io.Writer
32+ stdInWriter io.Reader
3033
3134 inputs bytes.Buffer
3235 stdOut bytes.Buffer
@@ -221,6 +224,22 @@ func (ui *FakeUI) Writer() io.Writer {
221224 return & ui .stdOut
222225}
223226
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+
224243func (ui * FakeUI ) SetQuiet (quiet bool ) {
225244 ui .quiet = quiet
226245}
You can’t perform that action at this time.
0 commit comments