aboutsummaryrefslogtreecommitdiffstats
path: root/commands/account/clear.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/account/clear.go')
-rw-r--r--commands/account/clear.go25
1 files changed, 5 insertions, 20 deletions
diff --git a/commands/account/clear.go b/commands/account/clear.go
index b67454dd..fd209d07 100644
--- a/commands/account/clear.go
+++ b/commands/account/clear.go
@@ -5,10 +5,11 @@ import (
"git.sr.ht/~rjarry/aerc/app"
"git.sr.ht/~rjarry/aerc/lib/state"
- "git.sr.ht/~sircmpwn/getopt"
)
-type Clear struct{}
+type Clear struct {
+ Selected bool `opt:"-s"`
+}
func init() {
register(Clear{})
@@ -22,7 +23,7 @@ func (Clear) Complete(args []string) []string {
return nil
}
-func (Clear) Execute(args []string) error {
+func (c Clear) Execute(args []string) error {
acct := app.SelectedAccount()
if acct == nil {
return errors.New("No account selected")
@@ -32,23 +33,7 @@ func (Clear) Execute(args []string) error {
return errors.New("Cannot perform action. Messages still loading")
}
- clearSelected := false
- opts, optind, err := getopt.Getopts(args, "s")
- if err != nil {
- return err
- }
-
- for _, opt := range opts {
- if opt.Option == 's' {
- clearSelected = true
- }
- }
-
- if len(args) != optind {
- return errors.New("Usage: clear [-s]")
- }
-
- if clearSelected {
+ if c.Selected {
defer store.Select(0)
}
store.ApplyClear()