aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account/next-folder.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account/next-folder.go')
-rw-r--r--commands/account/next-folder.go29
1 files changed, 6 insertions, 23 deletions
diff --git a/commands/account/next-folder.go b/commands/account/next-folder.go
index 2b23e6da..1b5651c8 100644
--- a/commands/account/next-folder.go
+++ b/commands/account/next-folder.go
@@ -2,13 +2,13 @@ package account
import (
"errors"
- "fmt"
- "strconv"
"git.sr.ht/~rjarry/aerc/app"
)
-type NextPrevFolder struct{}
+type NextPrevFolder struct {
+ Offset int `opt:"n" default:"1"`
+}
func init() {
register(NextPrevFolder{})
@@ -22,32 +22,15 @@ func (NextPrevFolder) Complete(args []string) []string {
return nil
}
-func (NextPrevFolder) Execute(args []string) error {
- if len(args) > 2 {
- return nextPrevFolderUsage(args[0])
- }
- var (
- n int = 1
- err error
- )
- if len(args) > 1 {
- n, err = strconv.Atoi(args[1])
- if err != nil {
- return nextPrevFolderUsage(args[0])
- }
- }
+func (np NextPrevFolder) Execute(args []string) error {
acct := app.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
}
if args[0] == "prev-folder" {
- acct.Directories().NextPrev(-n)
+ acct.Directories().NextPrev(-np.Offset)
} else {
- acct.Directories().NextPrev(n)
+ acct.Directories().NextPrev(np.Offset)
}
return nil
}
-
-func nextPrevFolderUsage(cmd string) error {
- return fmt.Errorf("Usage: %s [n]", cmd)
-}