diff options
author | Robin Jarry <robin@jarry.cc> | 2023-10-28 18:30:20 +0200 |
---|---|---|
committer | Robin Jarry <robin@jarry.cc> | 2023-10-28 19:24:44 +0200 |
commit | 803a10d4fabbd30533721db2f5efaefbccd88cdd (patch) | |
tree | fc188851ed00da0008b59280dd3335b272b4152b /main.go | |
parent | b336a5c9e19adba31bec1da51e093a11e09a8ead (diff) | |
download | aerc-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.go | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 { |