1088b4f5fSWarner Losh-- 2088b4f5fSWarner Losh-- Copyright (c) 2015 Pedro Souza <pedrosouza@freebsd.org> 3*afad05b2SKyle Evans-- Copyright (c) 2018 Kyle Evans <kevans@FreeBSD.org> 4088b4f5fSWarner Losh-- All rights reserved. 5088b4f5fSWarner Losh-- 6088b4f5fSWarner Losh-- Redistribution and use in source and binary forms, with or without 7088b4f5fSWarner Losh-- modification, are permitted provided that the following conditions 8088b4f5fSWarner Losh-- are met: 9088b4f5fSWarner Losh-- 1. Redistributions of source code must retain the above copyright 10088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer. 11088b4f5fSWarner Losh-- 2. Redistributions in binary form must reproduce the above copyright 12088b4f5fSWarner Losh-- notice, this list of conditions and the following disclaimer in the 13088b4f5fSWarner Losh-- documentation and/or other materials provided with the distribution. 14088b4f5fSWarner Losh-- 15088b4f5fSWarner Losh-- THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16088b4f5fSWarner Losh-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17088b4f5fSWarner Losh-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18088b4f5fSWarner Losh-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19088b4f5fSWarner Losh-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20088b4f5fSWarner Losh-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21088b4f5fSWarner Losh-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22088b4f5fSWarner Losh-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23088b4f5fSWarner Losh-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24088b4f5fSWarner Losh-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25088b4f5fSWarner Losh-- SUCH DAMAGE. 26088b4f5fSWarner Losh-- 27088b4f5fSWarner Losh-- $FreeBSD$ 28088b4f5fSWarner Losh-- 29088b4f5fSWarner Losh 30088b4f5fSWarner Loshconfig = require("config"); 31088b4f5fSWarner Loshmenu = require("menu"); 32088b4f5fSWarner Loshpassword = require("password"); 33088b4f5fSWarner Losh 34*afad05b2SKyle Evans-- Declares a global function cli_execute that attempts to dispatch the 35*afad05b2SKyle Evans-- arguments passed as a lua function. This gives lua a chance to intercept 36*afad05b2SKyle Evans-- builtin CLI commands like "boot" 37*afad05b2SKyle Evansfunction cli_execute(...) 38*afad05b2SKyle Evans local cmd_name, cmd_args = ...; 39*afad05b2SKyle Evans local cmd = _G[cmd_name]; 40*afad05b2SKyle Evans if (cmd ~= nil) and (type(cmd) == "function") then 41*afad05b2SKyle Evans -- Pass argv wholesale into cmd. We could omit argv[0] since the 42*afad05b2SKyle Evans -- traditional reasons for including it don't necessarily apply, 43*afad05b2SKyle Evans -- it may not be totally redundant if we want to have one global 44*afad05b2SKyle Evans -- handling multiple commands 45*afad05b2SKyle Evans cmd(...); 46*afad05b2SKyle Evans else 47*afad05b2SKyle Evans loader.command(...); 48*afad05b2SKyle Evans end 49*afad05b2SKyle Evans 50*afad05b2SKyle Evansend 51*afad05b2SKyle Evans 52088b4f5fSWarner Loshconfig.load(); 53088b4f5fSWarner Loshpassword.check(); 54088b4f5fSWarner Loshmenu.run(); 55