esxlib/pkg/pprint/csv.go

32 lines
580 B
Go
Raw Normal View History

2023-06-24 19:57:08 +00:00
package pprint
import (
"fmt"
"io"
)
type CSVPrinter struct {
writer io.Writer
}
// Headers specify the table headers
func (p *CSVPrinter) Headers(headers ...string) {
for _, header := range headers {
fmt.Fprintf(p.writer, "%s,", header)
}
fmt.Fprintf(p.writer, "\n")
}
// Fields add another row
func (p *CSVPrinter) Fields(fields ...interface{}) {
for _, header := range fields {
fmt.Fprintf(p.writer, "%v,", header)
}
fmt.Fprintf(p.writer, "\n")
}
// Flush implements the flush interface but for CVS printer is a noop
func (p *CSVPrinter) Flush() {
// noop
}