returns either json or table representation of the result
(flagOutputFormat string, v messageType, tableWriter f)
| 62 | |
| 63 | // returns either json or table representation of the result |
| 64 | func EncodeOutput[messageType tabulatedData, f func(messageType) error](flagOutputFormat string, v messageType, tableWriter f) error { |
| 65 | switch flagOutputFormat { |
| 66 | case FormatJSON: |
| 67 | return EncodeJSON(v) |
| 68 | case FormatTable: |
| 69 | return tableWriter(v) |
| 70 | default: |
| 71 | return ErrOutputFormatNotImplemented |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | func EncodeJSON(v interface{}) error { |
| 76 | return EncodeJSONToWriter(v, os.Stdout) |
no test coverage detected