blob: f91d885b39e3b93c46afb9958af2f6e19552f93c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
package msg
import (
"fmt"
"time"
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/worker/types"
)
type Copy struct {
CreateFolders bool `opt:"-p"`
Folder string `opt:"folder" complete:"CompleteFolder"`
}
func init() {
register(Copy{})
}
func (Copy) Aliases() []string {
return []string{"cp", "copy"}
}
func (*Copy) CompleteFolder(arg string) []string {
return commands.GetFolders(arg)
}
func (c Copy) Execute(args []string) error {
h := newHelper()
uids, err := h.markedOrSelectedUids()
if err != nil {
return err
}
store, err := h.store()
if err != nil {
return err
}
store.Copy(uids, c.Folder,
c.CreateFolders, func(
msg types.WorkerMessage,
) {
switch msg := msg.(type) {
case *types.Done:
var s string
if len(uids) > 1 {
s = "%d messages copied to %s"
} else {
s = "%d message copied to %s"
}
app.PushStatus(fmt.Sprintf(s, len(uids), c.Folder), 10*time.Second)
store.Marker().ClearVisualMark()
case *types.Error:
app.PushError(msg.Error.Error())
}
})
return nil
}
|