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/account/cf.go | 10 ++++------ commands/account/mkdir.go | 5 +++-- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'commands/account') diff --git a/commands/account/cf.go b/commands/account/cf.go index cbef308..65b8810 100644 --- a/commands/account/cf.go +++ b/commands/account/cf.go @@ -28,7 +28,7 @@ func (ChangeFolder) Complete(aerc *widgets.Aerc, args []string) []string { } func (ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) < 2 { + if len(args) == 1 { return errors.New("Usage: cf ") } acct := aerc.SelectedAccount() @@ -36,17 +36,15 @@ func (ChangeFolder) Execute(aerc *widgets.Aerc, args []string) error { return errors.New("No account selected") } previous := acct.Directories().Selected() - if args[1] == "-" { + joinedArgs := strings.Join(args[1:], " ") + if joinedArgs == "-" { if dir, ok := history[acct.Name()]; ok { acct.Directories().Select(dir) } else { return errors.New("No previous folder to return to") } } else { - if len(args) > 2 { - args[1] = strings.Join(args[1:], " ") - } - acct.Directories().Select(args[1]) + acct.Directories().Select(joinedArgs) } history[acct.Name()] = previous diff --git a/commands/account/mkdir.go b/commands/account/mkdir.go index d42928e..bb7e38a 100644 --- a/commands/account/mkdir.go +++ b/commands/account/mkdir.go @@ -2,6 +2,7 @@ package account import ( "errors" + "strings" "time" "github.com/gdamore/tcell" @@ -25,14 +26,14 @@ func (MakeDir) Complete(aerc *widgets.Aerc, args []string) []string { } func (MakeDir) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) != 2 { + if len(args) == 0 { return errors.New("Usage: :mkdir ") } acct := aerc.SelectedAccount() if acct == nil { return errors.New("No account selected") } - name := args[1] + name := strings.Join(args[1:], " ") acct.Worker().PostAction(&types.CreateDirectory{ Directory: name, }, func(msg types.WorkerMessage) { -- cgit v1.2.3