aboutsummaryrefslogtreecommitdiff
path: root/commands/compose/edit.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/compose/edit.go')
-rw-r--r--commands/compose/edit.go27
1 files changed, 7 insertions, 20 deletions
diff --git a/commands/compose/edit.go b/commands/compose/edit.go
index 1e8e0672..198259e2 100644
--- a/commands/compose/edit.go
+++ b/commands/compose/edit.go
@@ -5,10 +5,12 @@ import (
"git.sr.ht/~rjarry/aerc/config"
"git.sr.ht/~rjarry/aerc/widgets"
- "git.sr.ht/~sircmpwn/getopt"
)
-type Edit struct{}
+type Edit struct {
+ Edit bool `opt:"-e"`
+ NoEdit bool `opt:"-E"`
+}
func init() {
register(Edit{})
@@ -22,30 +24,15 @@ func (Edit) Complete(aerc *widgets.Aerc, args []string) []string {
return nil
}
-func (Edit) Execute(aerc *widgets.Aerc, args []string) error {
+func (e Edit) Execute(aerc *widgets.Aerc, args []string) error {
composer, ok := aerc.SelectedTabContent().(*widgets.Composer)
if !ok {
return errors.New("only valid while composing")
}
- editHeaders := config.Compose.EditHeaders
- opts, optind, err := getopt.Getopts(args, "eE")
- if err != nil {
- return err
- }
- if len(args) != optind {
- return errors.New("Usage: edit [-e|-E]")
- }
- for _, opt := range opts {
- switch opt.Option {
- case 'e':
- editHeaders = true
- case 'E':
- editHeaders = false
- }
- }
+ editHeaders := (config.Compose.EditHeaders || e.Edit) && !e.NoEdit
- err = composer.ShowTerminal(editHeaders)
+ err := composer.ShowTerminal(editHeaders)
if err != nil {
return err
}