diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-10 00:08:31 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-10 11:38:01 +0200 |
commit | bc176bd61ba726351a489cabf4da16a47dc5ec3b (patch) | |
tree | bbf06f731592d072f3d6f76f1648d61989375f2e /commands/msg/forward.go | |
parent | 598e4a5803578ab3e291f232d6aad31b4efd8ea4 (diff) | |
download | aerc-bc176bd61ba726351a489cabf4da16a47dc5ec3b.tar.gz |
app: export global functions
The single Aerc object is passed around in almost all command functions.
This hinders readability.
Store the single Aerc instance as a global variable. Export public
functions from the app package to access methods of that object. Remove
all explicit references to *app.Aerc and replace them with calls to
these functions. For references to private/unexported fields and
functions from within the app package, directly access the global aerc
object.
Signed-off-by: Robin Jarry <robin@jarry.cc>
Acked-by: Moritz Poldrack <moritz@poldrack.dev>
Diffstat (limited to 'commands/msg/forward.go')
-rw-r--r-- | commands/msg/forward.go | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go index d1abbc5b..68f162cc 100644 --- a/commands/msg/forward.go +++ b/commands/msg/forward.go @@ -34,11 +34,11 @@ func (forward) Aliases() []string { return []string{"forward"} } -func (forward) Complete(aerc *app.Aerc, args []string) []string { +func (forward) Complete(args []string) []string { return nil } -func (forward) Execute(aerc *app.Aerc, args []string) error { +func (forward) Execute(args []string) error { opts, optind, err := getopt.Getopts(args, "AFT:eE") if err != nil { return err @@ -69,7 +69,7 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { return errors.New("Options -A and -F are mutually exclusive") } - widget := aerc.SelectedTabContent().(app.ProvidesMessage) + widget := app.SelectedTabContent().(app.ProvidesMessage) acct := widget.SelectedAccount() if acct == nil { return errors.New("No account selected") @@ -107,15 +107,15 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { } addTab := func() (*app.Composer, error) { - composer, err := app.NewComposer(aerc, acct, + composer, err := app.NewComposer(acct, acct.AccountConfig(), acct.Worker(), editHeaders, template, h, &original, nil) if err != nil { - aerc.PushError("Error: " + err.Error()) + app.PushError("Error: " + err.Error()) return nil, err } - composer.Tab = aerc.NewTab(composer, subject) + composer.Tab = app.NewTab(composer, subject) if !h.Has("to") { composer.FocusEditor("to") } else { @@ -210,7 +210,7 @@ func (forward) Execute(aerc *app.Aerc, args []string) error { mu.Unlock() if err != nil { log.Errorf(err.Error()) - aerc.PushError(err.Error()) + app.PushError(err.Error()) } }) } |