aboutsummaryrefslogtreecommitdiff
path: root/stand/lua/loader.lua
diff options
context:
space:
mode:
authorKyle Evans <kevans@FreeBSD.org>2018-02-20 17:46:50 +0000
committerKyle Evans <kevans@FreeBSD.org>2018-02-20 17:46:50 +0000
commitafad05b233255f283e08163376d0b34bc149adf8 (patch)
tree6daa8367a7fd623648fdb06499d5ba6c158c96ba /stand/lua/loader.lua
parenta83546e5914f9733631d59202a0d76eb3ca9df61 (diff)
Notes
Diffstat (limited to 'stand/lua/loader.lua')
-rw-r--r--stand/lua/loader.lua19
1 files changed, 19 insertions, 0 deletions
diff --git a/stand/lua/loader.lua b/stand/lua/loader.lua
index cdf875d1ce02..b1aef5b13bbd 100644
--- a/stand/lua/loader.lua
+++ b/stand/lua/loader.lua
@@ -1,5 +1,6 @@
--
-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org>
+-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
@@ -30,6 +31,24 @@ config = require("config");
menu = require("menu");
password = require("password");
+-- Declares a global function cli_execute that attempts to dispatch the
+-- arguments passed as a lua function. This gives lua a chance to intercept
+-- builtin CLI commands like "boot"
+function cli_execute(...)
+ local cmd_name, cmd_args = ...;
+ local cmd = _G[cmd_name];
+ if (cmd ~= nil) and (type(cmd) == "function") then
+ -- Pass argv wholesale into cmd. We could omit argv[0] since the
+ -- traditional reasons for including it don't necessarily apply,
+ -- it may not be totally redundant if we want to have one global
+ -- handling multiple commands
+ cmd(...);
+ else
+ loader.command(...);
+ end
+
+end
+
config.load();
password.check();
menu.run();