Fix @command form not supporting global options

This commit is contained in:
Kovid Goyal
2022-08-22 16:06:05 +05:30
parent eec8f04e93
commit 7457746d65
2 changed files with 63 additions and 34 deletions

View File

@@ -483,3 +483,17 @@ func Init(root *cobra.Command) {
func Execute(root *cobra.Command) error {
return root.Execute()
}
type FlagValGetter struct {
Flags *pflag.FlagSet
Err error
}
func (self *FlagValGetter) String(name string) string {
if self.Err != nil {
return ""
}
ans, err := self.Flags.GetString(name)
self.Err = err
return ans
}