about summary refs log tree commit diff stats
path: root/commands/msgview
diff options
context:
space:
mode:
authorJeffas <dev@jeffas.io>2019-09-20 17:16:29 +0100
committerDrew DeVault <sir@cmpwn.com>2019-09-20 15:06:34 -0400
commit39307a6fa7e96641b822ed0a9acb75021dcf7fe9 (patch)
tree683aec09eb86e2077148a53429681aa39776449b /commands/msgview
parent3ec9fd216d9e3b38d1d5abb5fba24199185f7054 (diff)
downloadaerc-39307a6fa7e96641b822ed0a9acb75021dcf7fe9.tar.gz
Make commands join args with spaces
This patch ensures the following commands join their arguments with
spaces to make it easier to interact with:

- cf
- mkdir
- cd
- attach
- detach
- ct
- copy
- move
- save
Diffstat (limited to 'commands/msgview')
-rw-r--r--commands/msgview/save.go18
1 files changed, 10 insertions, 8 deletions
diff --git a/commands/msgview/save.go b/commands/msgview/save.go
index 3b38ec7..33cd45f 100644
--- a/commands/msgview/save.go
+++ b/commands/msgview/save.go
@@ -11,9 +11,11 @@ import (
 	"strings"
 	"time"
 
-	"git.sr.ht/~sircmpwn/aerc/widgets"
 	"git.sr.ht/~sircmpwn/getopt"
 	"github.com/mitchellh/go-homedir"
+
+	"git.sr.ht/~sircmpwn/aerc/commands"
+	"git.sr.ht/~sircmpwn/aerc/widgets"
 )
 
 type Save struct{}
@@ -27,10 +29,14 @@ func (Save) Aliases() []string {
 }
 
 func (Save) Complete(aerc *widgets.Aerc, args []string) []string {
-	return nil
+	path := strings.Join(args, " ")
+	return commands.CompletePath(path)
 }
 
 func (Save) Execute(aerc *widgets.Aerc, args []string) error {
+	if len(args) == 1 {
+		return errors.New("Usage: :save [-p] <path>")
+	}
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
@@ -38,7 +44,7 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
 
 	var (
 		mkdirs bool
-		path   string
+		path   string = strings.Join(args[optind:], " ")
 	)
 
 	for _, opt := range opts {
@@ -47,12 +53,8 @@ func (Save) Execute(aerc *widgets.Aerc, args []string) error {
 			mkdirs = true
 		}
 	}
-	if len(args) == optind+1 {
-		path = args[optind]
-	} else if defaultPath := aerc.Config().General.DefaultSavePath; defaultPath != "" {
+	if defaultPath := aerc.Config().General.DefaultSavePath; defaultPath != "" {
 		path = defaultPath
-	} else {
-		return errors.New("Usage: :save [-p] <path>")
 	}
 
 	mv := aerc.SelectedTab().(*widgets.MessageViewer)