blob: 4109ef99fc90229ae838dcdd35afa1462e311603 (
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
|
package msg
import (
"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:"..." metavar:"<folder>"`
}
func init() {
register(Copy{})
}
func (Copy) Aliases() []string {
return []string{"cp", "copy"}
}
func (Copy) Complete(args []string) []string {
return commands.GetFolders(args)
}
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:
app.PushStatus("Messages copied.", 10*time.Second)
store.Marker().ClearVisualMark()
case *types.Error:
app.PushError(msg.Error.Error())
}
})
return nil
}
|