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>
This commit is contained in:
parent
fb0e9e3e41
commit
6a87d8be72
|
@ -41,10 +41,18 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
}
|
}
|
||||||
attach := false
|
attach := false
|
||||||
template := ""
|
template := ""
|
||||||
|
var tolist []*mail.Address
|
||||||
for _, opt := range opts {
|
for _, opt := range opts {
|
||||||
switch opt.Option {
|
switch opt.Option {
|
||||||
case 'A':
|
case 'A':
|
||||||
attach = true
|
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':
|
case 'T':
|
||||||
template = opt.Value
|
template = opt.Value
|
||||||
}
|
}
|
||||||
|
@ -69,12 +77,7 @@ func (forward) Execute(aerc *widgets.Aerc, args []string) error {
|
||||||
subject := "Fwd: " + msg.Envelope.Subject
|
subject := "Fwd: " + msg.Envelope.Subject
|
||||||
h.SetSubject(subject)
|
h.SetSubject(subject)
|
||||||
|
|
||||||
if len(args) != 1 {
|
if len(tolist) > 0 {
|
||||||
to := strings.Join(args[optind:], ", ")
|
|
||||||
tolist, err := mail.ParseAddressList(to)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("invalid to address(es): %v", err)
|
|
||||||
}
|
|
||||||
h.SetAddressList("to", tolist)
|
h.SetAddressList("to", tolist)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue