Skip to content

Commit 4863a83

Browse files
authored
fix: included all flags in metadata (#449)
1 parent e74c292 commit 4863a83

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

plugin/plugin.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff 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
112112
func 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 != "" {

testhelpers/terminal/test_ui.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,10 @@ func (ui *FakeUI) Writer() io.Writer {
221221
return &ui.stdOut
222222
}
223223

224+
func (ui *FakeUI) ErrWriter() io.Writer {
225+
return &ui.stdErr
226+
}
227+
224228
func (ui *FakeUI) SetQuiet(quiet bool) {
225229
ui.quiet = quiet
226230
}

0 commit comments

Comments
 (0)