Page MenuHomeFreeBSD

loader: create a generic vendor sub-menu place holder
ClosedPublic

Authored by imp on Mar 31 2021, 12:44 AM.
Tags
None
Referenced Files
F81602250: D29505.id86654.diff
Thu, Apr 18, 7:18 PM
Unknown Object (File)
Thu, Apr 11, 2:36 PM
Unknown Object (File)
Thu, Apr 11, 1:49 PM
Unknown Object (File)
Sun, Apr 7, 8:51 PM
Unknown Object (File)
Tue, Apr 2, 8:44 PM
Unknown Object (File)
Sun, Mar 31, 6:38 AM
Unknown Object (File)
Fri, Mar 29, 9:30 AM
Unknown Object (File)
Thu, Mar 21, 7:06 AM
Subscribers
None

Details

Summary

Add a dummy vendor menu entry on the main welcome menu. Vendors can override
this in their local.lua file to create whatever sub-menu they need for their
products.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 38233
Build 35122: arc lint + arc unit

Event Timeline

imp requested review of this revision.Mar 31 2021, 12:44 AM
imp added inline comments.
stand/lua/menu.lua.8
204

Kyle pointed out in email something that makes me want to retract this entire paragraph.
It's possible, and we should document it.

+1 in advance for the idea of creating a vendor entry and changing the example to just reference using the vendor entry. I'll likely come back through after and add an example of modifying a submenu or something (e.g., adding another boot option) just to have one of those covered.

Actually, you can go ahead and tack this on there after the vendor example; I suspect the vendor example will be more useful to folks and the below is just for informational purposes.

local color = require('color')
local core = require('core')
local menu = require('menu')

-- This is a silly example that rotates local_option through the values
-- 0 to 4.  local_option would still need to be used elsewhere.
local local_option = 0

-- The `entries` of a menu may either be a table or a function.  In this
-- example we're augmenting a menu that just has a static table, but if we
-- wanted to be more robust then we would need to instead check the type
-- of `stock_options` here to determine our next move.
--
-- If `entries` is a table, then the stock menu system won't be changing it
-- so we can just add our menu option as we do below.
--
-- If `entries` is a function, then we would need to provide a new function to
-- replace `entries` that does a core.deepCopyTable() of the result and adds
-- the below item to it.  The deep copy is necessary to avoid duplicating our
-- new menu item and allowing the menu to alter its behavior however it pleases.
local stock_options = menu.boot_options.entries
stock_options[#stock_options + 1] = {
	entry_type = core.MENU_ENTRY,
	name = function()
		return color.highlight('L') ..
		    "ocal Option     : " .. local_option
	end,
	func = function()
		local_option = (local_option + 1) % 5
	end,
	alias= {"l", "L"}
}

Update with the suggestions from Kyle.
I didn't do the rename / redirect thing you suggested in email, though... should I?

One last round of example polishing.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 1 2021, 4:05 AM
This revision was automatically updated to reflect the committed changes.