summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLee Marlow <lee.marlow@gmail.com>2022-11-03 14:16:17 -0600
committerMaas Lalani <maas@lalani.dev>2022-11-07 10:09:56 -0500
commite20d3a97f0c54aa8c7464cfefe00faaf904301c6 (patch)
tree858fd13a85db9783c825036809e6bf6fec4abe01
parent5ed1f2b1b82f3977920b2b3cfbaf54f29664e9a1 (diff)
Use encoding/csv to write proper CSV for the selected row
-rw-r--r--table/command.go7
1 files 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
}