From e20d3a97f0c54aa8c7464cfefe00faaf904301c6 Mon Sep 17 00:00:00 2001 From: Lee Marlow Date: Thu, 3 Nov 2022 14:16:17 -0600 Subject: [PATCH] Use encoding/csv to write proper CSV for the selected row --- table/command.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/table/command.go b/table/command.go index 1b90a70..bdd774c 100644 --- a/table/command.go +++ b/table/command.go @@ -4,7 +4,6 @@ import ( "encoding/csv" "fmt" "os" - "strings" "github.com/alecthomas/kong" "github.com/charmbracelet/bubbles/table" @@ -102,7 +101,11 @@ func (o Options) Run() error { } m := tm.(model) - fmt.Println(strings.Join([]string(m.selected), o.Separator)) + + w := csv.NewWriter(os.Stdout) + w.Comma = reader.Comma + w.Write([]string(m.selected)) + w.Flush() return nil }