aboutsummaryrefslogtreecommitdiffstats
path: root/commands/compose/attach-key.go
diff options
context:
space:
mode:
authorTim Culverhouse <tim@timculverhouse.com>2022-05-05 12:53:16 -0500
committerRobin Jarry <robin@jarry.cc>2022-05-06 11:02:55 +0200
commitb57fceaad4bfcbd4ca3022e013b73eff72079c0b (patch)
tree7e68b206ca5b5dd7d1e2a8793360a80963c0c1df /commands/compose/attach-key.go
parent32a16dcd8dc488c1f360553d9d9f6d121af1b367 (diff)
downloadaerc-b57fceaad4bfcbd4ca3022e013b73eff72079c0b.tar.gz
pgp: add attach key command
Add compose command ("attach-key") to attach the public key associated with the sending account. Public key is attached in ascii armor format, with the mimetype set according to RFC 3156 ("application/pgp-keys"). Signed-off-by: Tim Culverhouse <tim@timculverhouse.com> Tested-by: Koni Marti <koni.marti@gmail.com>
Diffstat (limited to 'commands/compose/attach-key.go')
-rw-r--r--commands/compose/attach-key.go32
1 files changed, 32 insertions, 0 deletions
diff --git a/commands/compose/attach-key.go b/commands/compose/attach-key.go
new file mode 100644
index 00000000..c12df446
--- /dev/null
+++ b/commands/compose/attach-key.go
@@ -0,0 +1,32 @@
+package compose
+
+import (
+ "errors"
+
+ "git.sr.ht/~rjarry/aerc/widgets"
+)
+
+type AttachKey struct{}
+
+func init() {
+ register(AttachKey{})
+}
+
+func (AttachKey) Aliases() []string {
+ return []string{"attach-key"}
+}
+
+func (AttachKey) Complete(aerc *widgets.Aerc, args []string) []string {
+ return nil
+}
+
+func (AttachKey) Execute(aerc *widgets.Aerc, args []string) error {
+ if len(args) != 1 {
+ return errors.New("Usage: attach-key")
+ }
+
+ composer, _ := aerc.SelectedTab().(*widgets.Composer)
+
+ composer.SetAttachKey(!composer.AttachKey())
+ return nil
+}