CLI.LUA(8)
πΈ CLI.LUA(8) πΈ
okay so bestie, this is a page from the System Manager's Manual and it's literally all about cli.lua, the bootloader command line interpreter module. it's giving "how to make the loader prompt do cool stuff" energy and i'm obsessed π
β¨
β¨ NAME β¨
cli.lua β bootloader command line interpreter module π
π DESCRIPTION π
cli.lua contains the main functionality required to add new CLI commands, which can be executed at the loader prompt. no cap, this is the module you need if you wanna teach the loader new tricks π§
Before hooking into the functionality provided by cli.lua, it must be included with a statement such as the following:
local cli = require("cli")
π¦ Adding new commands π¦
New loader commands may be created by adding functions to the object returned by requiring the cli.lua module. periodt π«
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 foo. Arguments may be passed to it as usual, space-delimited. slay π«Ά
π Default Commands π
The cli.lua module provides the following default commands:
autobootbootboot-confreload-confdisable-devicedisable-moduleenable-moduletoggle-moduleshow-module-options
For autoboot, boot, and boot-conf, the core.lua(8) module will load all ELF modules as-needed before executing the equivalent built-in loader commands. All non-kernel arguments to these commands are passed in the same order to the loader command. iykyk π
The reload-conf command will reload the configuration from disk. This is useful if you have manually changed currdev and would like to easily reload the configuration from the new device. lowkey handy fr fr π
The enable-module, disable-module, and toggle-module commands manipulate the list of modules to be loaded along with the kernel. Modules blacklisted are considered disabled by toggle-module. These commands will override any such restriction as needed. The show-module-options command will dump the list of modules that loader has been made aware of and any applicable options using paged output. main character energy πβ¨
The disable-device command sets the environment variable that disables the device argument. π
π Exported Functions π
The following functions are exported from cli.lua:
cli.arguments(...)β Takes varargs passed on the stack fromloader(8)tocli_execute, splits them out into two return values: the command name, traditionallyargv[0], and the rest ofargv. literally so useful ππ
π₯ SEE ALSO π₯
loader.conf(5), core.lua(8), loader(8)
π« AUTHORS π«
The cli.lua file was originally written by Kyle Evans <kevans@FreeBSD.org>. iconic behavior ngl ππ
stay slaying, bestie! this page is from Debian, dated March 29, 2025 β go forth and CLI in style πππ¦
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- π the page's license: BSD-2-Clause
- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms