about summary refs log tree commit diff stats
path: root/commands/ct.go
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/ct.go
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/ct.go')
-rw-r--r--commands/ct.go16
1 files changed, 9 insertions, 7 deletions
diff --git a/commands/ct.go b/commands/ct.go
index 3cae0bd..8b6e8a8 100644
--- a/commands/ct.go
+++ b/commands/ct.go
@@ -23,9 +23,10 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
 	if len(args) == 0 {
 		return aerc.TabNames()
 	}
+	joinedArgs := strings.Join(args, " ")
 	out := make([]string, 0)
 	for _, tab := range aerc.TabNames() {
-		if strings.HasPrefix(tab, args[0]) {
+		if strings.HasPrefix(tab, joinedArgs) {
 			out = append(out, tab)
 		}
 	}
@@ -33,22 +34,23 @@ func (ChangeTab) Complete(aerc *widgets.Aerc, args []string) []string {
 }
 
 func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
-	if len(args) != 2 {
+	if len(args) == 1 {
 		return fmt.Errorf("Usage: %s <tab>", args[0])
 	}
-	if args[1] == "-" {
+	joinedArgs := strings.Join(args[1:], " ")
+	if joinedArgs == "-" {
 		ok := aerc.SelectPreviousTab()
 		if !ok {
 			return errors.New("No previous tab to return to")
 		}
 	} else {
-		n, err := strconv.Atoi(args[1])
+		n, err := strconv.Atoi(joinedArgs)
 		if err == nil {
-			if strings.HasPrefix(args[1], "+") {
+			if strings.HasPrefix(joinedArgs, "+") {
 				for ; n > 0; n-- {
 					aerc.NextTab()
 				}
-			} else if strings.HasPrefix(args[1], "-") {
+			} else if strings.HasPrefix(joinedArgs, "-") {
 				for ; n < 0; n++ {
 					aerc.PrevTab()
 				}
@@ -60,7 +62,7 @@ func (ChangeTab) Execute(aerc *widgets.Aerc, args []string) error {
 				}
 			}
 		} else {
-			ok := aerc.SelectTab(args[1])
+			ok := aerc.SelectTab(joinedArgs)
 			if !ok {
 				return errors.New("No tab with that name")
 			}