summary refs log tree commit diff stats
path: root/commands/msg
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/msg
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/msg')
-rw-r--r--commands/msg/copy.go28
-rw-r--r--commands/msg/move.go12
2 files changed, 22 insertions, 18 deletions
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index d6b78d3..48b296c 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -2,6 +2,7 @@ package msg
 
 import (
 	"errors"
+	"strings"
 	"time"
 
 	"git.sr.ht/~sircmpwn/getopt"
@@ -27,13 +28,13 @@ func (Copy) Complete(aerc *widgets.Aerc, args []string) []string {
 }
 
 func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
+	if len(args) == 1 {
+		return errors.New("Usage: cp [-p] <folder>")
+	}
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
 	}
-	if optind != len(args)-1 {
-		return errors.New("Usage: cp [-p] <folder>")
-	}
 	var (
 		createParents bool
 	)
@@ -53,16 +54,17 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
 	if err != nil {
 		return err
 	}
-	store.Copy([]uint32{msg.Uid}, args[optind], createParents, func(
-		msg types.WorkerMessage) {
+	store.Copy([]uint32{msg.Uid}, strings.Join(args[optind:], " "),
+		createParents, func(
+			msg types.WorkerMessage) {
 
-		switch msg := msg.(type) {
-		case *types.Done:
-			aerc.PushStatus("Messages copied.", 10*time.Second)
-		case *types.Error:
-			aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second).
-				Color(tcell.ColorDefault, tcell.ColorRed)
-		}
-	})
+			switch msg := msg.(type) {
+			case *types.Done:
+				aerc.PushStatus("Messages copied.", 10*time.Second)
+			case *types.Error:
+				aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second).
+					Color(tcell.ColorDefault, tcell.ColorRed)
+			}
+		})
 	return nil
 }
diff --git a/commands/msg/move.go b/commands/msg/move.go
index 2f8c61e..d7e1ea9 100644
--- a/commands/msg/move.go
+++ b/commands/msg/move.go
@@ -2,6 +2,7 @@ package msg
 
 import (
 	"errors"
+	"strings"
 	"time"
 
 	"git.sr.ht/~sircmpwn/getopt"
@@ -27,13 +28,13 @@ func (Move) Complete(aerc *widgets.Aerc, args []string) []string {
 }
 
 func (Move) Execute(aerc *widgets.Aerc, args []string) error {
+	if len(args) == 1 {
+		return errors.New("Usage: mv [-p] <folder>")
+	}
 	opts, optind, err := getopt.Getopts(args, "p")
 	if err != nil {
 		return err
 	}
-	if optind != len(args)-1 {
-		return errors.New("Usage: mv [-p] <folder>")
-	}
 	var (
 		createParents bool
 	)
@@ -63,12 +64,13 @@ func (Move) Execute(aerc *widgets.Aerc, args []string) error {
 	}
 	store.Next()
 	acct.Messages().Scroll()
-	store.Move([]uint32{msg.Uid}, args[optind], createParents, func(
+	joinedArgs := strings.Join(args[optind:], " ")
+	store.Move([]uint32{msg.Uid}, joinedArgs, createParents, func(
 		msg types.WorkerMessage) {
 
 		switch msg := msg.(type) {
 		case *types.Done:
-			aerc.PushStatus("Message moved to "+args[optind], 10*time.Second)
+			aerc.PushStatus("Message moved to "+joinedArgs, 10*time.Second)
 		case *types.Error:
 			aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second).
 				Color(tcell.ColorDefault, tcell.ColorRed)
'#n302'>302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392