lualoader: Pull argument extraction for cli functions into cli.arguments

This will be the translation layer for varargs -> cmd_name, argv for cli
commands. We reserve the right to break exactly what the varargs inclulde,
but this gives us a stable way to pull the arguments out of varargs.
This commit is contained in:
Kyle Evans 2018-02-22 01:44:30 +00:00
parent 613b0d87da
commit eca5ca66d0

View File

@ -67,9 +67,7 @@ end
-- Globals -- Globals
function boot(...) function boot(...)
local argv = {...} local cmd_name, argv = cli.arguments(...)
local cmd_name = ""
cmd_name, argv = core.popFrontTable(argv)
local kernel, argstr = parse_boot_args(argv) local kernel, argstr = parse_boot_args(argv)
if kernel ~= nil then if kernel ~= nil then
loader.perform("unload") loader.perform("unload")
@ -79,9 +77,7 @@ function boot(...)
end end
function autoboot(...) function autoboot(...)
local argv = {...} local cmd_name, argv = cli.arguments(...)
local cmd_name = ""
cmd_name, argv = core.popFrontTable(argv)
local argstr = parse_boot_args(argv, false) local argstr = parse_boot_args(argv, false)
core.autoboot(argstr) core.autoboot(argstr)
end end
@ -111,4 +107,13 @@ function cli_execute(...)
end end
-- Module exports
function cli.arguments(...)
local argv = {...}
local cmd_name = ""
cmd_name, argv = core.popFrontTable(argv)
return cmd_name, argv
end
return cli return cli