From d72913b37e684de2d4cdadbf8121c1702e66b418 Mon Sep 17 00:00:00 2001 From: Felix Ingram Date: Tue, 12 Jun 2018 22:20:50 +0100 Subject: [PATCH] Add double quotes to csv output if needed --- console/displayer.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/console/displayer.go b/console/displayer.go index bb9ec522e..a50193c5c 100644 --- a/console/displayer.go +++ b/console/displayer.go @@ -405,7 +405,11 @@ func (d *csvDisplayer) Print(w io.Writer) error { for i := range values { var props []string for j, h := range d.columnDefinitions { - props = append(props, h.format(values[i][j])) + val := h.format(values[i][j]) + if strings.Contains(val, ",") { + val = "\"" + val + "\"" + } + props = append(props, val) } buff.WriteString(strings.Join(props, ",") + "\n") }