aboutsummaryrefslogtreecommitdiff
path: root/stand/lua/cli.lua
Commit message (Collapse)AuthorAgeFilesLines
* Revert "loader/lua: Remove pager shim"Warner Losh2024-07-291-0/+12
| | | | | | | | | | | | This reverts commit 8b9178cd0d35ff2beafebdd51c8c44ba2b5aeb0f. Really old loader.efi files persist in the field. Revert this to support it. We need to support this through at least 14.2 now, alas. MFC After: 3 days Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D45881
* loader/lua: Remove pager shimWarner Losh2024-02-291-12/+0
| | | | | | | | | | | | Just after 12.2 and before the stable/13 branch, kevans added lpager.c to provide a pager interface for commands written in lua. It was merged into 12.3. Now that 12.2 is long since EOL, we can remove the pager shim here. Nobody needs that old loader + new lua scripts. Plus only one command is affected. Sponsored by: Netflix Reviewed by: kevans Differential Revision: https://reviews.freebsd.org/D44142
* Remove $FreeBSD$: two-line lua tagWarner Losh2023-08-161-2/+0
| | | | Remove /^--\n--\s*\$FreeBSD\$.*$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* lua loader: Add disable-device to disable a device.Warner Losh2021-07-281-0/+15
| | | | | | | | | disable-device fooX will set hint.foo.X.disabled=1 as a way to easily disable a device attaching during boot. Reviewed by: tsoome Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D31297
* lualoader: fix lua-lint runKyle Evans2020-12-171-1/+1
| | | | | | | | | | | luacheck rightfully complains that i is unused in the show-module-options loop at the end (it was used for some debugging in the process). We've added a new pager module that's compiled in, so declare that as an acceptable global. Notes: svn path=/head/; revision=368729
* lualoader: cli: provide a show-module-options loader commandKyle Evans2020-12-171-0/+67
| | | | | | | | | | | | | This effectively dumps everything lualoader knows about to the console using the libsa pager; that particular lua interface was added in r368591. A pager stub implementation has been added that just dumps the output as-is as a compat shim for older loader binaries that do not have lpager. This stub should be moved into a more appropriate .lua file if we add anything else that needs the pager. Notes: svn path=/head/; revision=368728
* lualoader: provide module-manipulation commandsKyle Evans2020-12-121-0/+39
| | | | | | | | | | | | | | | | | | Specifically, we have: - enable-module - disable-module - toggle-module These can be used to add/remove modules to be loaded or force modules to be loaded in spite of modules_blacklist. In the typical case, a user is expected to use them to recover an issue happening due to a module directive they've added to their loader.conf or because they discover that they've under-specified what to load. MFC after: 1 week Notes: svn path=/head/; revision=368575
* lualoader: clear up some luacheck warningsKyle Evans2020-10-011-1/+1
| | | | | | | | | | | - One (1) unused argument - One (1) trailing whitespace - Two (2) "non-standard global" (curenv, rewind) tools/boot/lua-lint.sh is once again happy. Notes: svn path=/head/; revision=366314
* lualoader: config: improve readConfFiles, rename to readConfKyle Evans2020-04-301-4/+1
| | | | | | | | | | | | | | | | | | | | | | The previous interface was pretty bad, and required the caller to get some implementation details correct that it really shouldn't need to (e.g. loader_conf_files handling) and pass in an empty table for it to use. The new and much improved interface, readConf, is much less of a hack; hiding these implementation details and just doing the right thing. config.lua will now use it to process /boot/defaults/loader.conf and the subsequent loader_conf_files from there, and read-conf will also use it. This improvement submitted by Olivier (cited below), loader_conf_files handling from the original patch was changed to just clobber it before processing and not bother restoring it after the fact following r360505 where it's now guaranteed to evade the loader environment. PR: 244640 Submitted by: Olivier Certner (olivier freebsd free fr> Notes: svn path=/head/; revision=360506
* lualoader: cli: clobber loader_conf_files before proceedingKyle Evans2020-04-281-0/+3
| | | | | | | | | | This makes sure that config.readConfFiles doesn't see a stale loader_conf_files from before, in case the newly loaded file doesn't set it. MFC after: 3 days Notes: svn path=/head/; revision=360423
* lualoader: cli: add read-confKyle Evans2020-04-281-0/+5
| | | | | | | | | | | | | This is a straightforward match to the command used by many in forthloader; it uses the newly-exported config.readConfFiles() to make sure that any loader_conf_files gets done as appropriate. PR: 244640 Submitted by: Olivier Certner <olivier freebsd free fr> MFC after: 3 days Notes: svn path=/head/; revision=360422
* lualoader: Add reload-conf loader commandKyle Evans2019-09-141-0/+4
| | | | | | | | | | | | | | | | This command will trigger a reload of the configuration from disk. This is useful if you've changed currdev from recovery media to local disk as much as I have over the past ~2 hours and are tired of the extra keystrokes. This is really just a glorified shortcut, but reload-conf is likely easier to remember for other people and does save some keystrokes when reloading the configuration. It is also resilient to the underlying config method changing interface, but this is unlikely to happen. MFC after: 1 week Notes: svn path=/head/; revision=352314
* lualoader: Implement boot-confKyle Evans2018-11-021-0/+10
| | | | | | | MFC after: 3 days Notes: svn path=/head/; revision=340040
* Remove "All Rights Reserved" on files that I hold sole copyright onKyle Evans2018-05-091-1/+0
| | | | | | | | See r333391 for more detail; in summary: it holds no weight and may be removed. Notes: svn path=/head/; revision=333418
* lualoader: Return status in cli_execute_unparsed properlyKyle Evans2018-03-071-1/+1
| | | | | | | | | | | | cli_execute was changed to return the status, cascade that to cli_execute_unparsed. This fixes a lot of false "Failed to execute" errors following r330620; no failures actually occurred, but [module]_error would've then promptly executed (and also "failed") Notes: svn path=/head/; revision=330625
* lualoader: Fix name, cli.execute_unparsed -> cli_execute_unparsedKyle Evans2018-03-071-1/+1
| | | | Notes: svn path=/head/; revision=330617
* lualoader: Expose loader.parse and add cli_execute_unparsedKyle Evans2018-03-071-0/+4
| | | | | | | | | | | | | | | | | This will be used for scenarios where the command to execute is coming in via the environment (from, for example, loader.conf(5)) and is thus not necessarily trusted. cli_execute_unparsed will immediately be used for handling module_{before,after,error} as well as menu_timeout_command. We still want to offer these variables the ability to execute Lua-intercepted loader commands, but we don't want them to be able to execute arbitrary Lua. Reviewed by: imp Differential Revision: https://reviews.freebsd.org/D14580 Notes: svn path=/head/; revision=330616
* lualoader: Return meaningful value in cli_executeKyle Evans2018-03-041-4/+3
| | | | | | | | | loader.command(...) will return whatever the executed function returns, so follow suit and return whatever loader.command() returned or whatever the Lua function returns. Notes: svn path=/head/; revision=330369
* lualoader: Explain deviation from naming guidelinesKyle Evans2018-02-251-0/+4
| | | | | | | | | cli_execute is likely the only exception that we should make, due to it being a global. We don't really need other globals, so this won't really end up an epidemic. Notes: svn path=/head/; revision=329949
* lualoader: Clean up naming conventions a little bitKyle Evans2018-02-241-4/+4
| | | | | | | | We mostly use camel case for function names, but some local functions got mixed in using internal underscores. Doubles down on camel case. Notes: svn path=/head/; revision=329927
* lualoader: Use "local function x()" instead of "local x = function()"Kyle Evans2018-02-231-1/+1
| | | | | | | | | The latter is good, but the former is more elegant and clear about what 'x' is. Adopt it, preferably only using the latter kind of notation where needed as values for tables. Notes: svn path=/head/; revision=329856
* Add SPDX tags to lua filesKyle Evans2018-02-231-0/+2
| | | | Notes: svn path=/head/; revision=329851
* lualoader: Address some 'luacheck' concernsKyle Evans2018-02-221-4/+4
| | | | | | | | | | | | | | | luacheck pointed out an assortment of issues, ranging from non-standard globals being created as well as unused parameters, variables, and redundant assignments. Using '_' as a placeholder for values unused (whether it be parameters unused or return values unused, assuming multiple return values) feels clean and gets the point across, so I've adopted it. It also helps flag candidates for cleanup later in some of the lambdas I've created, giving me an easy way to re-evaluate later if we're still not using some of these features. Notes: svn path=/head/; revision=329809
* lualoader: Attach cli command functions to cli moduleKyle Evans2018-02-221-19/+18
| | | | | | | | | | | | | Instead of the global namespace, let's attach these to the cli module. Other users, including the "local" module, can attach functions to the cli module at will to add other cli commands and things will still Just Work. This distills down the candidates for functions that may be invoked via the cli to a minimal set (boot, autoboot, arguments), rather than any function that happens to live in the global lua namespace. Notes: svn path=/head/; revision=329786
* lualoader: Pull argument extraction for cli functions into cli.argumentsKyle Evans2018-02-221-6/+11
| | | | | | | | | 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. Notes: svn path=/head/; revision=329784
* lualoader: Unbreak 'boot [kernel]' by including configKyle Evans2018-02-221-1/+2
| | | | Notes: svn path=/head/; revision=329782
* lualoader: Split cli bits out into a cli moduleKyle Evans2018-02-221-0/+113
This module will, in the not-so-distant future, grow functionality for reducing boilerplate in functions that implement cli commands. It will likely also house most in-tree cli commands. Notes: svn path=/head/; revision=329779