aboutsummaryrefslogtreecommitdiffstats
path: root/commands/msg
diff options
context:
space:
mode:
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 d6b78d3d..48b296c4 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 2f8c61ea..d7e1ea95 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)