From 39307a6fa7e96641b822ed0a9acb75021dcf7fe9 Mon Sep 17 00:00:00 2001 From: Jeffas Date: Fri, 20 Sep 2019 17:16:29 +0100 Subject: 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 --- commands/msgview/save.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) (limited to 'commands/msgview') 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] ") + } 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] ") } mv := aerc.SelectedTab().(*widgets.MessageViewer) -- cgit v1.2.3