aboutsummaryrefslogtreecommitdiff
path: root/commands/quit.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/quit.go')
-rw-r--r--commands/quit.go23
1 files changed, 5 insertions, 18 deletions
diff --git a/commands/quit.go b/commands/quit.go
index 09791a74..a02b183b 100644
--- a/commands/quit.go
+++ b/commands/quit.go
@@ -1,15 +1,15 @@
package commands
import (
- "errors"
"fmt"
"git.sr.ht/~rjarry/aerc/commands/mode"
"git.sr.ht/~rjarry/aerc/widgets"
- "git.sr.ht/~sircmpwn/getopt"
)
-type Quit struct{}
+type Quit struct {
+ Force bool `opt:"-f"`
+}
func init() {
register(Quit{})
@@ -29,21 +29,8 @@ func (err ErrorExit) Error() string {
return "exit"
}
-func (Quit) Execute(aerc *widgets.Aerc, args []string) error {
- force := false
- opts, optind, err := getopt.Getopts(args, "f")
- if err != nil {
- return err
- }
- for _, opt := range opts {
- if opt.Option == 'f' {
- force = true
- }
- }
- if len(args) != optind {
- return errors.New("Usage: quit [-f]")
- }
- if force || mode.QuitAllowed() {
+func (q Quit) Execute(aerc *widgets.Aerc, args []string) error {
+ if q.Force || mode.QuitAllowed() {
return ErrorExit(1)
}
return fmt.Errorf("A task is not done yet. Use -f to force an exit.")