Fixes bug where path did not get updated after save-as. Also adds extensions as needed to given save paths.

This commit is contained in:
sloum 2021-03-18 20:10:13 -07:00
parent 5eb59cf6c6
commit cd7108da7d
1 changed files with 11 additions and 0 deletions

11
main.go
View File

@ -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