diff --git a/core/output/table.go b/core/output/table.go index b8740da..91885e6 100644 --- a/core/output/table.go +++ b/core/output/table.go @@ -41,7 +41,6 @@ func (f *TableFormatter) Format(list *interfaces.ResourceList) (io.Reader, error // Setup table t := table.NewWriter() - t.SetOutputMirror(outputBuffer) t.SetStyle(table.StyleLight) // Write header @@ -66,15 +65,22 @@ func (f *TableFormatter) Format(list *interfaces.ResourceList) (io.Reader, error } // Render - switch f.RenderFormat { - case tableFormatCSV: - t.RenderCSV() - case tableFormatHTML: - t.RenderHTML() - case tableFormatMarkdown: - t.RenderMarkdown() - default: - t.Render() + output := func() string { + switch f.RenderFormat { + case tableFormatCSV: + return t.RenderCSV() + case tableFormatHTML: + return t.RenderHTML() + case tableFormatMarkdown: + return t.RenderMarkdown() + default: + return t.Render() + } + }() + + _, err := outputBuffer.WriteString(output) + if err != nil { + return nil, fmt.Errorf("failed to write rendered table: %w", err) } return outputBuffer, nil