(cmd *cobra.Command, object interface{})
| 11 | ) |
| 12 | |
| 13 | func PrintObject(cmd *cobra.Command, object interface{}) error { |
| 14 | format, err := cmd.Flags().GetString("output-format") |
| 15 | if err != nil { |
| 16 | return err |
| 17 | } |
| 18 | |
| 19 | switch format { |
| 20 | case "json": |
| 21 | return printJSONObject(cmd, object) |
| 22 | case "tree": |
| 23 | return printUIObject(cmd, object) |
| 24 | default: |
| 25 | return fmt.Errorf("unknown output format: %s", format) |
| 26 | } |
| 27 | } |
| 28 | |
| 29 | func printJSONObject(cmd *cobra.Command, object interface{}) error { |
| 30 | b, err := json.MarshalIndent(object, "", " ") |
no test coverage detected