about summary refs log tree commit diff stats
path: root/commands
diff options
context:
space:
mode:
Diffstat (limited to 'commands')
-rw-r--r--commands/compose/detach.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/commands/compose/detach.go b/commands/compose/detach.go
new file mode 100644
index 0000000..e700ab6
--- /dev/null
+++ b/commands/compose/detach.go
@@ -0,0 +1,55 @@
+package compose
+
+import (
+	"fmt"
+	"time"
+
+	"git.sr.ht/~sircmpwn/aerc/widgets"
+	"github.com/gdamore/tcell"
+)
+
+type Detach struct{}
+
+func init() {
+	register(Detach{})
+}
+
+func (_ Detach) Aliases() []string {
+	return []string{"detach"}
+}
+
+func (_ Detach) Complete(aerc *widgets.Aerc, args []string) []string {
+	composer, _ := aerc.SelectedTab().(*widgets.Composer)
+
+	return composer.GetAttachments()
+}
+
+func (_ Detach) Execute(aerc *widgets.Aerc, args []string) error {
+	var path string
+	composer, _ := aerc.SelectedTab().(*widgets.Composer)
+
+	if len(args) > 2 {
+		return fmt.Errorf("Usage: :detach [path]")
+	}
+
+	if len(args) == 2 {
+		path = args[1]
+	} else {
+		// if no attachment is specified, delete the first in the list
+		atts := composer.GetAttachments()
+		if len(atts) > 0 {
+			path = atts[0]
+		} else {
+			return fmt.Errorf("No attachments to delete")
+		}
+	}
+
+	if err := composer.DeleteAttachment(path); err != nil {
+		return err
+	}
+
+	aerc.PushStatus(fmt.Sprintf("Detached %s", path), 10*time.Second).
+		Color(tcell.ColorDefault, tcell.ColorGreen)
+
+	return nil
+}
5 07:07:16 +0200 committer Reto Brunner <reto@labrat.space> 2020-09-15 07:07:16 +0200 Update go-imap to latest commit' href='/akspecs/aerc/commit/go.sum?h=0.5.0&id=84549e917de8b408c62db207757e84cc985facbe'>84549e9 ^
43dba93 ^

b6bcf89 ^

f3158b3 ^

b6bcf89 ^
89f1684 ^
43c4f2f ^

f3158b3 ^

b6bcf89 ^
331b915 ^
89f1684 ^

b6bcf89 ^

89f1684 ^

bbdf9df ^

6473848 ^

56b84d3 ^

89f1684 ^

b0eaf51 ^
974b22c ^
c4deaf2 ^
89f1684 ^


072bc26 ^
c4deaf2 ^
0c2ede5 ^
b2fa5a1 ^

c4deaf2 ^
072bc26 ^
89f1684 ^

32fd585 ^
89f1684 ^

b6bcf89 ^
974b22c ^

89f1684 ^

1170893 ^
89f1684 ^

32fd585 ^
89f1684 ^



513e8aa ^

89f1684 ^

c4deaf2 ^
8d20e92 ^
974b22c ^

072bc26 ^
c4deaf2 ^
974b22c ^
c4deaf2 ^
974b22c ^
8d20e92 ^
c4deaf2 ^
8d20e92 ^
c4deaf2 ^
3f452ca ^
855362d ^
b0eaf51 ^

072bc26 ^
f3158b3 ^
974b22c ^
89f1684 ^



b0eaf51 ^
072bc26 ^
f3158b3 ^
84f49e9 ^
89f1684 ^


648ca98 ^
072bc26 ^
84549e9 ^

072bc26 ^

b0eaf51 ^
c4deaf2 ^
89f1684 ^
c4deaf2 ^
89f1684 ^
c4deaf2 ^
974b22c ^
c4deaf2 ^
89f1684 ^
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129