From 159fb38daf5336758abc425447cf2c2ed51de59a Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Mon, 4 Dec 2023 23:39:49 +0100 Subject: commands: refactor registration Register all commands with the same function and store them in the same map. Use bit flags to determine in which contexts each command should be available. Remove duplicate commands now that the same command can be exposed in multiple contexts. Refactor API to allow executing commands from other commands without import cycles. Signed-off-by: Robin Jarry Tested-by: Bence Ferdinandy Tested-by: Johannes Thyssen Tishman --- commands/msg/envelope.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'commands/msg/envelope.go') diff --git a/commands/msg/envelope.go b/commands/msg/envelope.go index 62a266b0..24867fc1 100644 --- a/commands/msg/envelope.go +++ b/commands/msg/envelope.go @@ -6,6 +6,7 @@ import ( "strings" "git.sr.ht/~rjarry/aerc/app" + "git.sr.ht/~rjarry/aerc/commands" "git.sr.ht/~rjarry/aerc/lib/format" "git.sr.ht/~rjarry/aerc/log" "git.sr.ht/~rjarry/aerc/models" @@ -18,7 +19,11 @@ type Envelope struct { } func init() { - register(Envelope{}) + commands.Register(Envelope{}) +} + +func (Envelope) Context() commands.CommandContext { + return commands.MESSAGE } func (Envelope) Aliases() []string { -- cgit