summaryrefslogtreecommitdiff
path: root/commands
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-04-14 12:13:44 -0500
committerRobin Jarry <robin@jarry.cc>2022-04-14 23:48:25 +0200
commit6a87d8be721d4fc371844c71cc4ecc2d85b01c79 (patch)
tree466f669b50c65e040c965dd807cb306304ad8d36 /commands
parentfb0e9e3e41cd263de139de0bf620cc69ee5d61ae (diff)
downloadaerc-6a87d8be721d4fc371844c71cc4ecc2d85b01c79.zip
forward: allow ':forward -A' with no address
Allow using the command ':forward -A' without specifying an email address inline. Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands')
-rw-r--r--commands/msg/forward.go15
1 files changed, 9 insertions, 6 deletions
diff --git a/commands/msg/forward.go b/commands/msg/forward.go
index c8e04f1..9b234ef 100644
--- a/commands/msg/forward.go
+++ b/commands/msg/forward.go
@@ -41,10 +41,18 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
}
attach := false
template := ""
+ var tolist []*mail.Address
for _, opt := range opts {
switch opt.Option {
case 'A':
attach = true
+ to := strings.Join(args[optind:], ", ")
+ if strings.Contains(to, "@") {
+ tolist, err = mail.ParseAddressList(to)
+ if err != nil {
+ return fmt.Errorf("invalid to address(es): %v", err)
+ }
+ }
case 'T':
template = opt.Value
}
@@ -69,12 +77,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
subject := "Fwd: " + msg.Envelope.Subject
h.SetSubject(subject)
- if len(args) != 1 {
- to := strings.Join(args[optind:], ", ")
- tolist, err := mail.ParseAddressList(to)
- if err != nil {
- return fmt.Errorf("invalid to address(es): %v", err)
- }
+ if len(tolist) > 0 {
h.SetAddressList("to", tolist)
}