Debian Codegraph @

commands/account/next-folder.go

raw
1 package account
2
3 import (
4 "errors"
5
6 "git.sr.ht/~rjarry/aerc/app"
7 "git.sr.ht/~rjarry/aerc/commands"
8 )
9
10 type NextPrevFolder struct {
11 Unseen bool `opt:"-u" desc:"Cycle to the next or previous folder in the sidebar with unseen emails."`
12 Offset int `opt:"n" minus:"true" default:"1"`
13 }
14
15 func init() {
16 commands.Register(NextPrevFolder{})
17 }
18
19 func (NextPrevFolder) Description() string {
20 return "Cycle to the next or previous folder shown in the sidebar."
21 }
22
23 func (NextPrevFolder) Context() commands.CommandContext {
24 return commands.MESSAGE_LIST
25 }
26
27 func (NextPrevFolder) Aliases() []string {
28 return []string{"next-folder", "prev-folder"}
29 }
30
31 func (np NextPrevFolder) Execute(args []string) error {
32 acct := app.SelectedAccount()
33 if acct == nil {
34 return errors.New("No account selected")
35 }
36 if args[0] == "prev-folder" {
37 acct.Directories().NextPrev(-np.Offset, np.Unseen)
38 } else {
39 acct.Directories().NextPrev(np.Offset, np.Unseen)
40 }
41 return nil
42 }