diff options
author | Koni Marti <koni.marti@gmail.com> | 2024-01-31 16:49:28 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-01-31 16:54:31 +0100 |
commit | b285b894c3de7299452e860fc060b673af279261 (patch) | |
tree | d3f834db15ffe749708d734c0b6cd0645de7aabf /commands/patch/drop.go | |
parent | f16b33f752bbc3086d08ba8fde034de48ab1c6d6 (diff) | |
download | aerc-b285b894c3de7299452e860fc060b673af279261.tar.gz |
commands: rename patch remove to patch drop
Rename the :patch remove command to :patch drop to better express the
this operation is the counter-part to :patch apply.
Signed-off-by: Koni Marti <koni.marti@gmail.com>
Acked-by: Robin Jarry <robin@jarry.cc>
Diffstat (limited to 'commands/patch/drop.go')
-rw-r--r-- | commands/patch/drop.go | 47 |
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 +} |