lualoader: Intercept the 'autoboot' cli command
This commit is contained in:
parent
f0cb3b6b25
commit
6d3bcc06e2
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=329674
@ -37,23 +37,33 @@ local compose_loader_cmd = function(cmd_name, argstr)
|
||||
return cmd_name;
|
||||
end
|
||||
|
||||
-- Internal function
|
||||
-- Parses arguments to boot and returns two values: kernel_name, argstr
|
||||
-- Defaults to nil and "" respectively.
|
||||
local parse_boot_args = function(argv)
|
||||
-- This will also parse arguments to autoboot, but the with_kernel argument
|
||||
-- will need to be explicitly overwritten to false
|
||||
local parse_boot_args = function(argv, with_kernel)
|
||||
if (#argv == 0) then
|
||||
return nil, "";
|
||||
end
|
||||
if (with_kernel == nil) then
|
||||
with_kernel = true;
|
||||
end
|
||||
local kernel_name;
|
||||
local argstr = "";
|
||||
|
||||
for k, v in ipairs(argv) do
|
||||
if (v:sub(1,1) ~= "-") then
|
||||
if (with_kernel) and (v:sub(1,1) ~= "-") then
|
||||
kernel_name = v;
|
||||
else
|
||||
argstr = argstr .. " " .. v;
|
||||
end
|
||||
end
|
||||
return kernel_name, argstr;
|
||||
if (with_kernel) then
|
||||
return kernel_name, argstr;
|
||||
else
|
||||
return argstr;
|
||||
end
|
||||
end
|
||||
|
||||
-- Globals
|
||||
@ -69,6 +79,14 @@ function boot(...)
|
||||
core.boot(argstr);
|
||||
end
|
||||
|
||||
function autoboot(...)
|
||||
local argv = {...}
|
||||
local cmd_name = "";
|
||||
cmd_name, argv = core.popFrontTable(argv);
|
||||
local argstr = parse_boot_args(argv, false);
|
||||
core.autoboot(argstr);
|
||||
end
|
||||
|
||||
-- Module exports
|
||||
-- Commonly appearing constants
|
||||
core.KEY_BACKSPACE = 8;
|
||||
|
Loading…
Reference in New Issue
Block a user