New call api.addAllowed() to add values to a field's allowed value list

This commit is contained in:
Jason Perkins 2013-09-17 14:59:13 -04:00
parent cf8b1b0f3a
commit 68c26b0e38

View File

@ -74,6 +74,36 @@
end
--
-- Add a new value to a field's list of allowed values.
--
-- @param fieldName
-- The name of the field to which to add the value.
-- @param value
-- The value to add. May be a single string value, or an array
-- of values.
--
function api.addAllowed(fieldName, value)
local field = premake.fields[fieldName]
if not field then
error("No such field: " .. fieldName, 2)
end
if not field.allowed then
field.allowed = {}
end
if type(value) == "table" then
field.allowed = table.join(field.allowed, value)
else
table.insert(field.allowed, value)
end
table.sort(field.allowed)
end
--
-- Find the right target object for a given scope.
--