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/cd.go | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) (limited to 'commands/cd.go') diff --git a/commands/cd.go b/commands/cd.go index 1d033e44..fa487e77 100644 --- a/commands/cd.go +++ b/commands/cd.go @@ -24,11 +24,7 @@ func (ChangeDirectory) Aliases() []string { } func (ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string { - path := "" - if len(args) >= 1 { - path = args[0] - } - + path := strings.Join(args, " ") completions := CompletePath(path) var dirs []string @@ -43,24 +39,22 @@ func (ChangeDirectory) Complete(aerc *widgets.Aerc, args []string) []string { } func (ChangeDirectory) Execute(aerc *widgets.Aerc, args []string) error { - if len(args) < 1 || len(args) > 2 { + if len(args) < 1 { return errors.New("Usage: cd [directory]") } cwd, err := os.Getwd() if err != nil { return err } - var target string - if len(args) == 1 { + target := strings.Join(args[1:], " ") + if target == "" { target = "~" - } else if args[1] == "-" { + } else if target == "-" { if previousDir == "" { return errors.New("No previous folder to return to") } else { target = previousDir } - } else { - target = args[1] } target, err = homedir.Expand(target) if err != nil { -- cgit