Merge pull request #82 from Blizzard/option-defaults-and-categories

add option default and category support.
This commit is contained in:
starkos 2015-05-25 19:43:20 -04:00
commit 01abeaa99e
2 changed files with 33 additions and 11 deletions

View File

@ -15,21 +15,38 @@
printf("Usage: premake5 [options] action [arguments]")
printf("")
-- filter all options by category.
local categories = {}
for option in premake.option.each() do
local cat = "OPTIONS - General"
if option.category then
cat = "OPTIONS - " .. options.category;
end
if categories[cat] then
table.insert(categories[cat], option)
else
categories[cat] = {option}
end
end
-- display all options
printf("OPTIONS")
printf("")
for option in premake.option.each() do
local trigger = option.trigger
local description = option.description
if (option.value) then trigger = trigger .. "=" .. option.value end
if (option.allowed) then description = description .. "; one of:" end
for k, options in pairs(categories) do
printf(k)
printf("")
for _, option in ipairs(options) do
local trigger = option.trigger
local description = option.description
if (option.value) then trigger = trigger .. "=" .. option.value end
if (option.allowed) then description = description .. "; one of:" end
printf(" --%-15s %s", trigger, description)
if (option.allowed) then
for _, value in ipairs(option.allowed) do
printf(" %-14s %s", value[1], value[2])
printf(" --%-15s %s", trigger, description)
if (option.allowed) then
for _, value in ipairs(option.allowed) do
printf(" %-14s %s", value[1], value[2])
end
end
printf("")
end
printf("")
end

View File

@ -88,6 +88,11 @@
-- add it to the master list
premake.option.list[opt.trigger] = opt
-- if it has a default value, set it.
if opt.default and not _OPTIONS[opt.trigger] then
_OPTIONS[opt.trigger] = opt.default
end
end