aboutsummaryrefslogtreecommitdiffstats
path: root/commands/patch/drop.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/patch/drop.go')
-rw-r--r--commands/patch/drop.go47
1 files changed, 47 insertions, 0 deletions
diff --git a/commands/patch/drop.go b/commands/patch/drop.go
new file mode 100644
index 00000000..06457c72
--- /dev/null
+++ b/commands/patch/drop.go
@@ -0,0 +1,47 @@
+package patch
+
+import (
+ "fmt"
+ "time"
+
+ "git.sr.ht/~rjarry/aerc/app"
+ "git.sr.ht/~rjarry/aerc/commands"
+ "git.sr.ht/~rjarry/aerc/lib/pama"
+ "git.sr.ht/~rjarry/aerc/log"
+)
+
+type Drop struct {
+ Tag string `opt:"tag" complete:"CompleteTag"`
+}
+
+func init() {
+ register(Drop{})
+}
+
+func (Drop) Context() commands.CommandContext {
+ return commands.GLOBAL
+}
+
+func (Drop) Aliases() []string {
+ return []string{"drop"}
+}
+
+func (*Drop) CompleteTag(arg string) []string {
+ patches, err := pama.New().CurrentPatches()
+ if err != nil {
+ log.Errorf("failed to get current patches: %v", err)
+ return nil
+ }
+ return commands.FilterList(patches, arg, nil)
+}
+
+func (r Drop) Execute(args []string) error {
+ patch := r.Tag
+ err := pama.New().DropPatch(patch)
+ if err != nil {
+ return err
+ }
+ app.PushStatus(fmt.Sprintf("Patch %s has been dropped", patch),
+ 10*time.Second)
+ return nil
+}