aboutsummaryrefslogtreecommitdiff
path: root/commands/msg/copy.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/msg/copy.go')
-rw-r--r--commands/msg/copy.go28
1 files changed, 7 insertions, 21 deletions
diff --git a/commands/msg/copy.go b/commands/msg/copy.go
index 7118e4f8..0fe3ae00 100644
--- a/commands/msg/copy.go
+++ b/commands/msg/copy.go
@@ -1,18 +1,17 @@
package msg
import (
- "errors"
- "strings"
"time"
- "git.sr.ht/~sircmpwn/getopt"
-
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/widgets"
"git.sr.ht/~rjarry/aerc/worker/types"
)
-type Copy struct{}
+type Copy struct {
+ CreateFolders bool `opt:"-p"`
+ Folder string `opt:"..." metavar:"FOLDER"`
+}
func init() {
register(Copy{})
@@ -26,20 +25,7 @@ func (Copy) Complete(aerc *widgets.Aerc, args []string) []string {
return commands.GetFolders(aerc, args)
}
-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
- }
- var createParents bool
- for _, opt := range opts {
- if opt.Option == 'p' {
- createParents = true
- }
- }
+func (c Copy) Execute(aerc *widgets.Aerc, args []string) error {
h := newHelper(aerc)
uids, err := h.markedOrSelectedUids()
if err != nil {
@@ -49,8 +35,8 @@ func (Copy) Execute(aerc *widgets.Aerc, args []string) error {
if err != nil {
return err
}
- store.Copy(uids, strings.Join(args[optind:], " "),
- createParents, func(
+ store.Copy(uids, c.Folder,
+ c.CreateFolders, func(
msg types.WorkerMessage,
) {
switch msg := msg.(type) {