From cd7108da7dfd16efa2cf6ca03a39585219408bc8 Mon Sep 17 00:00:00 2001 From: sloum Date: Thu, 18 Mar 2021 20:10:13 -0700 Subject: [PATCH] Fixes bug where path did not get updated after save-as. Also adds extensions as needed to given save paths. --- main.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/main.go b/main.go index b43812e..c6176de 100644 --- a/main.go +++ b/main.go @@ -39,7 +39,12 @@ func runCommand(elems []string) { case "write", "w": if len(elems) >= 2 { path := ExpandedAbsFilepath(strings.Join(elems[1:], " ")) + if filepath.Ext(path) == "" { + path = path + ".tss" + } WriteFile(path) + wb.path = path + wb.name = filepath.Base(path) } else { path := wb.path ext := filepath.Ext(path) @@ -52,6 +57,9 @@ func runCommand(elems []string) { case "write-csv", "wc": if len(elems) >= 2 { path := ExpandedAbsFilepath(strings.Join(elems[1:], " ")) + if filepath.Ext(path) == "" { + path = path + ".csv" + } WriteCsv(path, false) } else { path := wb.path @@ -64,6 +72,9 @@ func runCommand(elems []string) { case "write-tsv", "wt": if len(elems) >= 2 { path := ExpandedAbsFilepath(strings.Join(elems[1:], " ")) + if filepath.Ext(path) == "" { + path = path + ".tsv" + } WriteCsv(path, true) } else { path := wb.path