aboutsummaryrefslogtreecommitdiffstats
path: root/commands/commands.go
diff options
context:
space:
mode:
Diffstat (limited to 'commands/commands.go')
-rw-r--r--commands/commands.go14
1 files changed, 5 insertions, 9 deletions
diff --git a/commands/commands.go b/commands/commands.go
index 1c303484..57f2e6dc 100644
--- a/commands/commands.go
+++ b/commands/commands.go
@@ -111,17 +111,13 @@ func templateData(
return data.Data()
}
-func (cmds *Commands) ExecuteCommand(cmdline string) error {
+func ExecuteCommand(cmd Command, cmdline string) error {
args := opt.LexArgs(cmdline)
- name, err := args.ArgSafe(0)
- if err != nil {
- return errors.New("Expected a command after template evaluation.")
- }
- if cmd, ok := cmds.dict()[name]; ok {
- log.Tracef("executing command %s", args.String())
- return cmd.Execute(args.Args())
+ if args.Count() == 0 {
+ return errors.New("No arguments")
}
- return NoSuchCommand(name)
+ log.Tracef("executing command %s", args.String())
+ return cmd.Execute(args.Args())
}
// expand template expressions