~sircmpwn/aerc

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH] Add optional body argument to compose command

Daniel Bridges
Details
Message ID
<20190812131545.66015-1-bridges2@gmail.com>
DKIM signature
pass
Download raw message
Patch: +15 -4
---
 commands/account/compose.go | 17 ++++++++++++++---
 doc/aerc.1.scd              |  2 +-
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/commands/account/compose.go b/commands/account/compose.go
index fa673f0..a4836b7 100644
--- a/commands/account/compose.go
+++ b/commands/account/compose.go
@@ -1,6 +1,7 @@
package account

import (
	"errors"
	"regexp"
	"strings"

@@ -22,7 +23,6 @@ func (_ Compose) Complete(aerc *widgets.Aerc, args []string) []string {
	return nil
}

// TODO: Accept arguments for message body
func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error {
	body, err := buildBody(args)
	if err != nil {
@@ -46,7 +46,7 @@ func (_ Compose) Execute(aerc *widgets.Aerc, args []string) error {

func buildBody(args []string) (string, error) {
	var body, headers string
	opts, _, err := getopt.Getopts(args, "H:")
	opts, optind, err := getopt.Getopts(args, "H:")
	if err != nil {
		return "", err
	}
@@ -62,8 +62,19 @@ func buildBody(args []string) (string, error) {
			}
		}
	}
	posargs := args[optind:]
	if len(posargs) > 1 {
		return "", errors.New("Usage: compose [-H] [body]")
	}
	if len(posargs) == 1 {
		body = posargs[0]
	}
	if headers != "" {
		body = headers + "\n\n"
		if len(body) > 0 {
			body = headers + "\n" + body
		} else {
			body = headers + "\n\n"
		}
	}
	return body, nil
}
diff --git a/doc/aerc.1.scd b/doc/aerc.1.scd
index 67bfba2..4356e8c 100644
--- a/doc/aerc.1.scd
+++ b/doc/aerc.1.scd
@@ -139,7 +139,7 @@ message list, the message in the message viewer, etc).
*cf* <folder>
	Change the folder shown in the message list.

*compose* [-H]
*compose* [-H] [body]
	Open the compose window to send a new email. The new email will be sent with
	the current account's outgoing transport configuration. For details on
	configuring outgoing mail delivery consult *aerc-config*(5).
-- 
2.20.1
Details
Message ID
<BW84IOM4BGKK.3EELWKU14YYH2@koishi>
In-Reply-To
<20190812131545.66015-1-bridges2@gmail.com> (view parent)
DKIM signature
pass
Download raw message
Pushed with a minor fix:

On Mon Aug 12, 2019 at 6:15 AM Daniel Bridges wrote:
> -*compose* [-H]
> +*compose* [-H] [body]

This should have been [<body>]. [] denotes an optional literal string,
and <> denotes a required arbitrary string. Together they denote an
optional arbitrary string.

Thanks!

To git.sr.ht:~sircmpwn/aerc
   5493af8..f0a0c5a  master -> master