|
NAMEcli.lua —
FreeBSD Lua CLI module
DESCRIPTIONcli.lua contains the main functionality required to add
new CLI commands, which can be executed at the loader prompt.
Before hooking into the functionality provided by
local cli =
require("cli") Adding new commandsNew loader commands may be created by adding functions to the object returned by requiring thecli.lua module.
For instance: local cli = require("cli") cli.foo = function(...) -- Expand args to command name and the rest of argv. These arguments -- are pushed directly to the stack by loader, then handed off to -- cli_execute. cli_execute then passes them on to the invoked -- function, where they appear as varargs that must be peeled apart into -- their respective components. local _, argv = cli.arguments(...) print("This is the foo command!") for k, v in ipairs(argv) do print("arg #" .. tostring(k) .. ": '" .. v .. "'") end -- Perform a loader command directly. This will not get dispatched back -- to Lua, so it is acceptable to have a function of the exact same name -- in loader. Lua will have the first chance to handle any commands -- executed at the loader prompt. loader.perform("foo") end This function may be invoked by a user at the loader prompt by
simply typing Default CommandsThecli.lua module provides the following default
commands:
For The The The Exported FunctionsThe following functions are exported fromcli.lua :
SEE ALSOloader.conf(5), core.lua(8), loader(8)AUTHORSThecli.lua file was originally written by
Kyle Evans
<kevans@FreeBSD.org>.
Visit the GSP FreeBSD Man Page Interface. |