aboutsummaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorRobin Jarry <robin@jarry.cc>2023-10-28 18:30:20 +0200
committerRobin Jarry <robin@jarry.cc>2023-10-28 19:24:44 +0200
commit803a10d4fabbd30533721db2f5efaefbccd88cdd (patch)
treefc188851ed00da0008b59280dd3335b272b4152b /main.go
parentb336a5c9e19adba31bec1da51e093a11e09a8ead (diff)
downloadaerc-803a10d4fabbd30533721db2f5efaefbccd88cdd.tar.gz
commands: expand templates before command resolution
Move the template expansion before the command name is looked up. It saves a few void renderings and will be required for the next commits. Signed-off-by: Robin Jarry <robin@jarry.cc> Tested-by: Inwit <inwit@sindominio.net>
Diffstat (limited to 'main.go')
-rw-r--r--main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/main.go b/main.go
index b72bf713..8ac70cf9 100644
--- a/main.go
+++ b/main.go
@@ -105,6 +105,10 @@ func execCommand(
cmdline string,
acct *config.AccountConfig, msg *models.MessageInfo,
) error {
+ cmdline, err := commands.ExpandTemplates(cmdline, acct, msg)
+ if err != nil {
+ return err
+ }
name, rest, didCut := strings.Cut(cmdline, " ")
cmds := getCommands(app.SelectedTabContent())
cmdline = expandAbbreviations(name, cmds)
@@ -112,7 +116,7 @@ func execCommand(
cmdline += " " + rest
}
for i, set := range cmds {
- err := set.ExecuteCommand(cmdline, acct, msg)
+ err := set.ExecuteCommand(cmdline)
if err != nil {
if errors.As(err, new(commands.NoSuchCommand)) {
if i == len(cmds)-1 {