feat(cli): add json output to coder speedtest (#13475)

This commit is contained in:
Ethan
2024-06-05 18:31:44 +10:00
committed by GitHub
parent 9a757f8e74
commit a4bba520a2
7 changed files with 227 additions and 39 deletions

View File

@ -7,6 +7,7 @@ import (
"reflect"
"strings"
"github.com/jedib0t/go-pretty/v6/table"
"golang.org/x/xerrors"
"github.com/coder/serpent"
@ -143,7 +144,11 @@ func (f *tableFormat) AttachOptions(opts *serpent.OptionSet) {
// Format implements OutputFormat.
func (f *tableFormat) Format(_ context.Context, data any) (string, error) {
return DisplayTable(data, f.sort, f.columns)
headers := make(table.Row, len(f.allColumns))
for i, header := range f.allColumns {
headers[i] = header
}
return renderTable(data, f.sort, headers, f.columns)
}
type jsonFormat struct{}