From 803a10d4fabbd30533721db2f5efaefbccd88cdd Mon Sep 17 00:00:00 2001 From: Robin Jarry Date: Sat, 28 Oct 2023 18:30:20 +0200 Subject: 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 Tested-by: Inwit --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'main.go') 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 { -- cgit