diff options
author | Robin Jarry <robin@jarry.cc> | 2023-12-04 23:39:49 +0100 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2024-01-20 21:56:25 +0100 |
commit | 159fb38daf5336758abc425447cf2c2ed51de59a (patch) | |
tree | e7be3bea878b12e441332f89d7bc3c63db477c05 /commands/prompt.go | |
parent | d2817371867e94b621de4054b235d53312db8073 (diff) | |
download | aerc-159fb38daf5336758abc425447cf2c2ed51de59a.tar.gz |
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 <robin@jarry.cc>
Tested-by: Bence Ferdinandy <bence@ferdinandy.com>
Tested-by: Johannes Thyssen Tishman <johannes@thyssentishman.com>
Diffstat (limited to 'commands/prompt.go')
-rw-r--r-- | commands/prompt.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/commands/prompt.go b/commands/prompt.go index 4fcf8a80..9ab2aac1 100644 --- a/commands/prompt.go +++ b/commands/prompt.go @@ -12,7 +12,11 @@ type Prompt struct { } func init() { - register(Prompt{}) + Register(Prompt{}) +} + +func (Prompt) Context() CommandContext { + return GLOBAL } func (Prompt) Aliases() []string { @@ -20,7 +24,7 @@ func (Prompt) Aliases() []string { } func (*Prompt) CompleteCommand(arg string) []string { - return FilterList(GlobalCommands.Names(), arg, nil) + return FilterList(ActiveCommandNames(), arg, nil) } func (p Prompt) Execute(args []string) error { |