(cmd *cobra.Command)
| 282 | } |
| 283 | |
| 284 | func validateOutputFormat(cmd *cobra.Command) error { |
| 285 | format, err := commandOutputFormatE(cmd) |
| 286 | if err != nil { |
| 287 | return err |
| 288 | } |
| 289 | if format == output.FormatJSON && !commandSupportsStructuredOutput(cmd) { |
| 290 | return output.ErrStructuredOutputUnsupported |
| 291 | } |
| 292 | return nil |
| 293 | } |
| 294 | |
| 295 | func commandSupportsStructuredOutput(cmd *cobra.Command) bool { |
| 296 | return cmd != nil && cmd.Annotations[structuredOutputSupportedAnnotation] == "true" |