aboutsummaryrefslogtreecommitdiffstats
path: root/commands/commands.go
diff options
context:
space:
mode:
authorDrew DeVault <sir@cmpwn.com>2019-03-10 21:15:24 -0400
committerDrew DeVault <sir@cmpwn.com>2019-03-10 21:15:24 -0400
commitb60999c39e11bf4d1e236f2b10a2f895b44d23fb (patch)
tree8ce8023277815a7d1f25dc7c48fa910c698d5b1b /commands/commands.go
parent62862d8a9e7f684bc3ff4e9ea115678ff44d8644 (diff)
downloadaerc-b60999c39e11bf4d1e236f2b10a2f895b44d23fb.tar.gz
Start building out command subsystem
Diffstat (limited to 'commands/commands.go')
-rw-r--r--commands/commands.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/commands/commands.go b/commands/commands.go
new file mode 100644
index 00000000..71dabe4c
--- /dev/null
+++ b/commands/commands.go
@@ -0,0 +1,28 @@
+package commands
+
+import (
+ "errors"
+
+ "git.sr.ht/~sircmpwn/aerc2/widgets"
+)
+
+type AercCommand func(aerc *widgets.Aerc, cmd string) error
+
+var (
+ commands map[string]AercCommand
+)
+
+func init() {
+ commands = make(map[string]AercCommand)
+}
+
+func Register(name string, cmd AercCommand) {
+ commands[name] = cmd
+}
+
+func ExecuteCommand(aerc *widgets.Aerc, cmd string) error {
+ if fn, ok := commands[cmd]; ok {
+ return fn(aerc, cmd)
+ }
+ return errors.New("Unknown command " + cmd)
+}