blob: 3e546acea4be670f340c7fb33cb130117fe78b1e (
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
|
package account
import (
"errors"
"time"
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/commands"
"git.sr.ht/~rjarry/aerc/worker/types"
)
type MakeDir struct {
Folder string `opt:"folder" complete:"CompleteFolder"`
}
func init() {
register(MakeDir{})
}
func (MakeDir) Aliases() []string {
return []string{"mkdir"}
}
func (*MakeDir) CompleteFolder(arg string) []string {
acct := app.SelectedAccount()
if acct == nil {
return nil
}
return commands.FilterList(
acct.Directories().List(), arg, "",
app.SelectedAccount().Worker().PathSeparator(),
app.SelectedAccountUiConfig().FuzzyComplete)
}
func (m MakeDir) Execute(args []string) error {
acct := app.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
}
acct.Worker().PostAction(&types.CreateDirectory{
Directory: m.Folder,
}, func(msg types.WorkerMessage) {
switch msg := msg.(type) {
case *types.Done:
app.PushStatus("Directory created.", 10*time.Second)
acct.Directories().Select(m.Folder)
case *types.Error:
app.PushError(msg.Error.Error())
}
})
return nil
}
|