aboutsummaryrefslogtreecommitdiffstats
path: root/commands/next-tab.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/next-tab.go')
-rw-r--r--commands/next-tab.go28
1 files changed, 5 insertions, 23 deletions
diff --git a/commands/next-tab.go b/commands/next-tab.go
index eb7b1ed1..d8374191 100644
--- a/commands/next-tab.go
+++ b/commands/next-tab.go
@@ -1,13 +1,12 @@
package commands
import (
- "fmt"
- "strconv"
-
"git.sr.ht/~rjarry/aerc/app"
)
-type NextPrevTab struct{}
+type NextPrevTab struct {
+ Offset int `opt:"n" default:"1"`
+}
func init() {
register(NextPrevTab{})
@@ -21,21 +20,8 @@ func (NextPrevTab) Complete(args []string) []string {
return nil
}
-func (NextPrevTab) Execute(args []string) error {
- if len(args) > 2 {
- return nextPrevTabUsage(args[0])
- }
- var (
- n int = 1
- err error
- )
- if len(args) > 1 {
- n, err = strconv.Atoi(args[1])
- if err != nil {
- return nextPrevTabUsage(args[0])
- }
- }
- for ; n > 0; n-- {
+func (np NextPrevTab) Execute(args []string) error {
+ for n := 0; n < np.Offset; n++ {
if args[0] == "prev-tab" {
app.PrevTab()
} else {
@@ -45,7 +31,3 @@ func (NextPrevTab) Execute(args []string) error {
app.UpdateStatus()
return nil
}
-
-func nextPrevTabUsage(cmd string) error {
- return fmt.Errorf("Usage: %s [n]", cmd)
-}