Implement :mkdir command
This commit is contained in:
parent
a98824af75
commit
d22a9140cd
2 changed files with 42 additions and 0 deletions
39
commands/account/mkdir.go
Normal file
39
commands/account/mkdir.go
Normal file
|
@ -0,0 +1,39 @@
|
|||
package account
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"time"
|
||||
|
||||
"github.com/gdamore/tcell"
|
||||
|
||||
"git.sr.ht/~sircmpwn/aerc/widgets"
|
||||
"git.sr.ht/~sircmpwn/aerc/worker/types"
|
||||
)
|
||||
|
||||
func init() {
|
||||
register("mkdir", Mkdir)
|
||||
}
|
||||
|
||||
func Mkdir(aerc *widgets.Aerc, args []string) error {
|
||||
if len(args) != 2 {
|
||||
return errors.New("Usage: :mkdir <name>")
|
||||
}
|
||||
acct := aerc.SelectedAccount()
|
||||
if acct == nil {
|
||||
return errors.New("No account selected")
|
||||
}
|
||||
name := args[1]
|
||||
acct.Worker().PostAction(&types.CreateDirectory{
|
||||
Directory: name,
|
||||
}, func(msg types.WorkerMessage) {
|
||||
switch msg := msg.(type) {
|
||||
case *types.Done:
|
||||
aerc.PushStatus("Directory created.", 10*time.Second)
|
||||
acct.Directories().Select(name)
|
||||
case *types.Error:
|
||||
aerc.PushStatus(" "+msg.Error.Error(), 10*time.Second).
|
||||
Color(tcell.ColorDefault, tcell.ColorRed)
|
||||
}
|
||||
})
|
||||
return nil
|
||||
}
|
|
@ -90,6 +90,9 @@ message list, the message in the message viewer, etc).
|
|||
the current account's outgoing transport configuration, see
|
||||
*aerc-config*(5) for details on configuring outgoing emails.
|
||||
|
||||
*mkdir* <name>
|
||||
Creates a new folder for this account and changes to that folder.
|
||||
|
||||
*next-folder* <n>, *prev-folder* <n>
|
||||
Cycles to the next (or previous) folder shown in the sidebar, repeated n
|
||||
times (default: 1).
|
||||
|
|
Loading…
Reference in a new issue