2014-01-03 18:37:57 -05:00
|
|
|
#!/usr/bin/lua
|
|
|
|
|
|
|
|
-- InfoDump.lua
|
|
|
|
|
2014-01-22 06:41:19 -05:00
|
|
|
--[[
|
|
|
|
Loads plugins' Info.lua and dumps its g_PluginInfo into various text formats
|
|
|
|
This is used for generating plugin documentation for the forum and for GitHub's INFO.md files
|
2014-01-03 18:37:57 -05:00
|
|
|
|
2014-01-22 06:41:19 -05:00
|
|
|
This script can be used in two ways:
|
|
|
|
Executing "lua InfoDump.lua" will go through all subfolders and dump each Info.lua file it can find
|
|
|
|
Note that this mode of operation requires LuaRocks with LFS installed; instructions are printed
|
|
|
|
when the prerequisites are not met.
|
|
|
|
Executing "lua InfoDump.lua PluginName" will load the Info.lua file from PluginName's folder and dump
|
|
|
|
only that one plugin's documentation. This mode of operation doesn't require LuaRocks
|
|
|
|
--]]
|
2014-01-03 18:37:57 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
-- Check Lua version. We use 5.1-specific construct when loading the plugin info, 5.2 is not compatible!
|
|
|
|
if (_VERSION ~= "Lua 5.1") then
|
2014-10-18 14:51:28 -04:00
|
|
|
print("Unsupported Lua version. This script requires Lua version 5.1, this Lua is version " .. (_VERSION or "<nil>"))
|
|
|
|
return
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-04 09:36:27 -05:00
|
|
|
--- Replaces generic formatting with forum-specific formatting
|
|
|
|
-- Also removes the single line-ends
|
|
|
|
local function ForumizeString(a_Str)
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_Str) == "string")
|
2014-01-04 09:36:27 -05:00
|
|
|
|
2014-01-06 04:25:52 -05:00
|
|
|
-- Remove the indentation, unless in the code tag:
|
|
|
|
-- Only one code or /code tag per line is supported!
|
2014-10-18 14:51:28 -04:00
|
|
|
local IsInCode = false
|
2014-01-06 04:25:52 -05:00
|
|
|
local function RemoveIndentIfNotInCode(s)
|
|
|
|
if (IsInCode) then
|
|
|
|
-- we're in code section, check if this line terminates it
|
2014-10-18 14:51:28 -04:00
|
|
|
IsInCode = (s:find("{%%/code}") ~= nil)
|
|
|
|
return s .. "\n"
|
2014-01-06 04:25:52 -05:00
|
|
|
else
|
|
|
|
-- we're not in code section, check if this line starts it
|
2014-10-18 14:51:28 -04:00
|
|
|
IsInCode = (s:find("{%%code}") ~= nil)
|
|
|
|
return s:gsub("^%s*", "") .. "\n"
|
2014-01-06 04:25:52 -05:00
|
|
|
end
|
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode)
|
2014-01-06 04:25:52 -05:00
|
|
|
|
2014-01-04 13:23:21 -05:00
|
|
|
-- Replace multiple line ends with {%p} and single line ends with a space,
|
2014-01-06 04:25:52 -05:00
|
|
|
-- so that manual word-wrap in the Info.lua file doesn't wrap in the forum.
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("\n\n", "{%%p}")
|
|
|
|
a_Str = a_Str:gsub("\n", " ")
|
2014-01-04 09:36:27 -05:00
|
|
|
|
|
|
|
-- Replace the generic formatting:
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("{%%p}", "\n\n")
|
|
|
|
a_Str = a_Str:gsub("{%%b}", "[b]"):gsub("{%%/b}", "[/b]")
|
|
|
|
a_Str = a_Str:gsub("{%%i}", "[i]"):gsub("{%%/i}", "[/i]")
|
|
|
|
a_Str = a_Str:gsub("{%%list}", "[list]"):gsub("{%%/list}", "[/list]")
|
|
|
|
a_Str = a_Str:gsub("{%%li}", "[*]"):gsub("{%%/li}", "")
|
2014-01-04 09:36:27 -05:00
|
|
|
-- TODO: Other formatting
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
return a_Str
|
2014-01-04 09:36:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
--- Replaces generic formatting with forum-specific formatting
|
|
|
|
-- Also removes the single line-ends
|
|
|
|
local function GithubizeString(a_Str)
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_Str) == "string")
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Remove the indentation, unless in the code tag:
|
|
|
|
-- Only one code or /code tag per line is supported!
|
2014-10-18 14:51:28 -04:00
|
|
|
local IsInCode = false
|
2014-02-05 15:50:35 -05:00
|
|
|
local function RemoveIndentIfNotInCode(s)
|
|
|
|
if (IsInCode) then
|
|
|
|
-- we're in code section, check if this line terminates it
|
2014-10-18 14:51:28 -04:00
|
|
|
IsInCode = (s:find("{%%/code}") ~= nil)
|
|
|
|
return s .. "\n"
|
2014-02-05 15:50:35 -05:00
|
|
|
else
|
|
|
|
-- we're not in code section, check if this line starts it
|
2014-10-18 14:51:28 -04:00
|
|
|
IsInCode = (s:find("{%%code}") ~= nil)
|
|
|
|
return s:gsub("^%s*", "") .. "\n"
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("(.-)\n", RemoveIndentIfNotInCode)
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Replace multiple line ends with {%p} and single line ends with a space,
|
|
|
|
-- so that manual word-wrap in the Info.lua file doesn't wrap in the forum.
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("\n\n", "{%%p}")
|
|
|
|
a_Str = a_Str:gsub("\n", " ")
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Replace the generic formatting:
|
2014-10-18 14:51:28 -04:00
|
|
|
a_Str = a_Str:gsub("{%%p}", "\n\n")
|
|
|
|
a_Str = a_Str:gsub("{%%b}", "**"):gsub("{%%/b}", "**")
|
|
|
|
a_Str = a_Str:gsub("{%%i}", "*"):gsub("{%%/i}", "*")
|
|
|
|
a_Str = a_Str:gsub("{%%list}", ""):gsub("{%%/list}", "")
|
|
|
|
a_Str = a_Str:gsub("{%%li}", " - "):gsub("{%%/li}", "")
|
2014-02-05 15:50:35 -05:00
|
|
|
-- TODO: Other formatting
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
return a_Str
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-03 18:37:57 -05:00
|
|
|
--- Builds an array of categories, each containing all the commands belonging to the category,
|
|
|
|
-- and the category description, if available.
|
|
|
|
-- Returns the array table, each item has the following format:
|
|
|
|
-- { Name = "CategoryName", Description = "CategoryDescription", Commands = {{CommandString = "/cmd verb", Info = {...}}, ...}}
|
|
|
|
local function BuildCategories(a_PluginInfo)
|
|
|
|
-- The returned result
|
|
|
|
-- This will contain both an array and a dict of the categories, to allow fast search
|
2014-10-18 14:51:28 -04:00
|
|
|
local res = {}
|
2014-01-03 18:37:57 -05:00
|
|
|
|
|
|
|
-- For each command add a reference to it into all of its categories:
|
|
|
|
local function AddCommands(a_CmdPrefix, a_Commands)
|
|
|
|
for cmd, info in pairs(a_Commands) do
|
|
|
|
local NewCmd =
|
|
|
|
{
|
|
|
|
CommandString = a_CmdPrefix .. cmd,
|
|
|
|
Info = info,
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((info.HelpString ~= nil) and (info.HelpString ~= "")) then
|
|
|
|
-- Add to each specified category:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Category = info.Category
|
2014-01-03 18:37:57 -05:00
|
|
|
if (type(Category) == "string") then
|
2014-10-18 14:51:28 -04:00
|
|
|
Category = {Category}
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
for idx, cat in ipairs(Category or {""}) do
|
2014-10-18 14:51:28 -04:00
|
|
|
local CatEntry = res[cat]
|
2014-01-03 18:37:57 -05:00
|
|
|
if (CatEntry == nil) then
|
|
|
|
-- First time we came across this category, create it:
|
2014-10-18 14:51:28 -04:00
|
|
|
local NewCat = {Name = cat, Description = "", Commands = {NewCmd}}
|
|
|
|
table.insert(res, NewCat)
|
|
|
|
res[cat] = NewCat
|
2014-01-03 18:37:57 -05:00
|
|
|
else
|
|
|
|
-- We already have this category, just add the command to its list of commands:
|
2014-10-18 14:51:28 -04:00
|
|
|
table.insert(CatEntry.Commands, NewCmd)
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
end -- for idx, cat - Category[]
|
|
|
|
end -- if (HelpString valid)
|
|
|
|
|
|
|
|
-- Recurse all subcommands:
|
|
|
|
if (info.Subcommands ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
AddCommands(a_CmdPrefix .. cmd .. " ", info.Subcommands)
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
end -- for cmd, info - a_Commands[]
|
|
|
|
end -- AddCommands()
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
AddCommands("", a_PluginInfo.Commands)
|
2014-01-03 18:37:57 -05:00
|
|
|
|
|
|
|
-- Assign descriptions to categories:
|
|
|
|
for name, desc in pairs(a_PluginInfo.Categories or {}) do
|
2014-10-18 14:51:28 -04:00
|
|
|
local CatEntry = res[name]
|
2014-01-03 18:37:57 -05:00
|
|
|
if (CatEntry ~= nil) then
|
|
|
|
-- The result has this category, add the description:
|
2014-10-18 14:51:28 -04:00
|
|
|
CatEntry.Description = desc.Description
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Alpha-sort each category's command list:
|
|
|
|
for idx, cat in ipairs(res) do
|
|
|
|
table.sort(cat.Commands,
|
|
|
|
function (cmd1, cmd2)
|
2014-10-18 14:51:28 -04:00
|
|
|
return (string.lower(cmd1.CommandString) < string.lower(cmd2.CommandString))
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
)
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
return res
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-22 04:18:58 -05:00
|
|
|
--- Returns a string specifying the command.
|
|
|
|
-- If a_Command is a simple string, returns a_Command colorized to blue
|
|
|
|
-- If a_Command is a table, expects members Name (full command name) and Params (command parameters),
|
|
|
|
-- colorizes command name blue and params green
|
|
|
|
local function GetCommandRefForum(a_Command)
|
|
|
|
if (type(a_Command) == "string") then
|
2014-10-18 14:51:28 -04:00
|
|
|
return "[color=blue]" .. a_Command .. "[/color]"
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
return "[color=blue]" .. a_Command.Name .. "[/color] [color=green]" .. (a_Command.Params or "") .. "[/color]"
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
--- Returns a string specifying the command.
|
|
|
|
-- If a_CommandParams is nil, returns a_CommandName apostrophed
|
|
|
|
-- If a_CommandParams is a string, apostrophes a_CommandName with a_CommandParams
|
|
|
|
local function GetCommandRefGithub(a_CommandName, a_CommandParams)
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_CommandName) == "string")
|
2014-02-05 15:50:35 -05:00
|
|
|
if (a_CommandParams == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return "`" .. a_CommandName .. "`"
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_CommandParams) == "table")
|
2014-02-05 15:50:35 -05:00
|
|
|
if ((a_CommandParams.Params == nil) or (a_CommandParams.Params == "")) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return "`" .. a_CommandName .. "`"
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_CommandParams.Params) == "string")
|
|
|
|
return "`" .. a_CommandName .. " " .. a_CommandParams.Params .. "`"
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-04 14:42:31 -05:00
|
|
|
--- Writes the specified command detailed help array to the output file, in the forum dump format
|
2014-01-06 04:25:52 -05:00
|
|
|
local function WriteCommandParameterCombinationsForum(a_CmdString, a_ParameterCombinations, f)
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_CmdString) == "string")
|
|
|
|
assert(type(a_ParameterCombinations) == "table")
|
|
|
|
assert(f ~= nil)
|
2014-01-04 14:42:31 -05:00
|
|
|
|
2014-01-06 04:25:52 -05:00
|
|
|
if (#a_ParameterCombinations == 0) then
|
2014-01-04 14:42:31 -05:00
|
|
|
-- No explicit parameter combinations to write
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-01-04 14:42:31 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("The following parameter combinations are recognized:\n")
|
2014-01-06 04:25:52 -05:00
|
|
|
for idx, combination in ipairs(a_ParameterCombinations) do
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("[color=blue]", a_CmdString, "[/color] [color=green]", combination.Params or "", "[/color]")
|
2014-01-06 04:25:52 -05:00
|
|
|
if (combination.Help ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" - ", ForumizeString(combination.Help))
|
2014-01-06 04:25:52 -05:00
|
|
|
end
|
2014-01-04 14:42:31 -05:00
|
|
|
if (combination.Permission ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" (Requires permission '[color=red]", combination.Permission, "[/color]')")
|
2014-01-04 14:42:31 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n")
|
2014-01-04 14:42:31 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
--- Writes the specified command detailed help array to the output file, in the forum dump format
|
|
|
|
local function WriteCommandParameterCombinationsGithub(a_CmdString, a_ParameterCombinations, f)
|
2014-10-18 14:51:28 -04:00
|
|
|
assert(type(a_CmdString) == "string")
|
|
|
|
assert(type(a_ParameterCombinations) == "table")
|
|
|
|
assert(f ~= nil)
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
if (#a_ParameterCombinations == 0) then
|
|
|
|
-- No explicit parameter combinations to write
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("The following parameter combinations are recognized:\n\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
for idx, combination in ipairs(a_ParameterCombinations) do
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(GetCommandRefGithub(a_CmdString, combination))
|
2014-02-05 15:50:35 -05:00
|
|
|
if (combination.Help ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" - ", GithubizeString(combination.Help))
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
if (combination.Permission ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" (Requires permission '**", combination.Permission, "**')")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-04 14:42:31 -05:00
|
|
|
--- Writes all commands in the specified category to the output file, in the forum dump format
|
2014-01-03 18:37:57 -05:00
|
|
|
local function WriteCommandsCategoryForum(a_Category, f)
|
|
|
|
-- Write category name:
|
2014-10-18 14:51:28 -04:00
|
|
|
local CategoryName = a_Category.Name
|
2014-01-03 18:37:57 -05:00
|
|
|
if (CategoryName == "") then
|
2014-10-18 14:51:28 -04:00
|
|
|
CategoryName = "General"
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[size=Large]", ForumizeString(a_Category.DisplayName or CategoryName), "[/size]\n")
|
2014-01-03 18:37:57 -05:00
|
|
|
|
|
|
|
-- Write description:
|
|
|
|
if (a_Category.Description ~= "") then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(ForumizeString(a_Category.Description), "\n")
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Write commands:
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[list]")
|
2014-01-03 18:37:57 -05:00
|
|
|
for idx2, cmd in ipairs(a_Category.Commands) do
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[b]", cmd.CommandString, "[/b] - ", ForumizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "\n")
|
2014-01-03 18:37:57 -05:00
|
|
|
if (cmd.Info.Permission ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("Permission required: [color=red]", cmd.Info.Permission, "[/color]\n")
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
if (cmd.Info.DetailedDescription ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(ForumizeString(cmd.Info.DetailedDescription))
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-01-06 04:25:52 -05:00
|
|
|
if (cmd.Info.ParameterCombinations ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
WriteCommandParameterCombinationsForum(cmd.CommandString, cmd.Info.ParameterCombinations, f)
|
2014-01-04 14:42:31 -05:00
|
|
|
end
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
f:write("[/list]\n\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
--- Writes all commands in the specified category to the output file, in the Github dump format
|
|
|
|
local function WriteCommandsCategoryGithub(a_Category, f)
|
|
|
|
-- Write category name:
|
2014-10-18 14:51:28 -04:00
|
|
|
local CategoryName = a_Category.Name
|
2014-02-05 15:50:35 -05:00
|
|
|
if (CategoryName == "") then
|
2014-10-18 14:51:28 -04:00
|
|
|
CategoryName = "General"
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n### ", GithubizeString(a_Category.DisplayName or CategoryName), "\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Write description:
|
|
|
|
if (a_Category.Description ~= "") then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(GithubizeString(a_Category.Description), "\n\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:53:58 -04:00
|
|
|
f:write("| Command | Permission | Description |\n")
|
|
|
|
f:write("| ------- | ---------- | ----------- |\n")
|
2014-03-02 10:48:55 -05:00
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
-- Write commands:
|
|
|
|
for idx2, cmd in ipairs(a_Category.Commands) do
|
2014-10-18 14:53:58 -04:00
|
|
|
f:write("|", cmd.CommandString, " | ", cmd.Info.Permission or "", " | ", GithubizeString(cmd.Info.HelpString or "UNDOCUMENTED"), "|\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
f:write("\n\n")
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-03 18:37:57 -05:00
|
|
|
local function DumpCommandsForum(a_PluginInfo, f)
|
|
|
|
-- Copy all Categories from a dictionary into an array:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Categories = BuildCategories(a_PluginInfo)
|
2014-01-03 18:37:57 -05:00
|
|
|
|
|
|
|
-- Sort the categories by name:
|
|
|
|
table.sort(Categories,
|
|
|
|
function(cat1, cat2)
|
2014-10-18 14:51:28 -04:00
|
|
|
return (string.lower(cat1.Name) < string.lower(cat2.Name))
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
)
|
2014-01-03 18:37:57 -05:00
|
|
|
|
2014-01-04 09:36:27 -05:00
|
|
|
if (#Categories == 0) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-01-04 09:36:27 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[size=X-Large]Commands[/size]\n")
|
2014-01-04 09:36:27 -05:00
|
|
|
|
2014-01-03 18:37:57 -05:00
|
|
|
-- Dump per-category commands:
|
|
|
|
for idx, cat in ipairs(Categories) do
|
2014-10-18 14:51:28 -04:00
|
|
|
WriteCommandsCategoryForum(cat, f)
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
local function DumpCommandsGithub(a_PluginInfo, f)
|
|
|
|
-- Copy all Categories from a dictionary into an array:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Categories = BuildCategories(a_PluginInfo)
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Sort the categories by name:
|
|
|
|
table.sort(Categories,
|
|
|
|
function(cat1, cat2)
|
2014-10-18 14:51:28 -04:00
|
|
|
return (string.lower(cat1.Name) < string.lower(cat2.Name))
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
)
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
if (#Categories == 0) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n# Commands\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
|
|
|
|
-- Dump per-category commands:
|
|
|
|
for idx, cat in ipairs(Categories) do
|
2014-10-18 14:51:28 -04:00
|
|
|
WriteCommandsCategoryGithub(cat, f)
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-04 09:36:27 -05:00
|
|
|
local function DumpAdditionalInfoForum(a_PluginInfo, f)
|
2014-10-18 14:51:28 -04:00
|
|
|
local AInfo = a_PluginInfo.AdditionalInfo
|
2014-02-05 15:50:35 -05:00
|
|
|
if (type(AInfo) ~= "table") then
|
2014-01-04 09:36:27 -05:00
|
|
|
-- There is no AdditionalInfo in a_PluginInfo
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-01-04 09:36:27 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do
|
|
|
|
if ((info.Title ~= nil) and (info.Contents ~= nil)) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[size=X-Large]", ForumizeString(info.Title), "[/size]\n")
|
|
|
|
f:write(ForumizeString(info.Contents), "\n")
|
2014-01-04 09:36:27 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
local function DumpAdditionalInfoGithub(a_PluginInfo, f)
|
2014-10-18 14:51:28 -04:00
|
|
|
local AInfo = a_PluginInfo.AdditionalInfo
|
2014-02-05 15:50:35 -05:00
|
|
|
if (type(AInfo) ~= "table") then
|
|
|
|
-- There is no AdditionalInfo in a_PluginInfo
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
for idx, info in ipairs(a_PluginInfo.AdditionalInfo) do
|
|
|
|
if ((info.Title ~= nil) and (info.Contents ~= nil)) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n# ", GithubizeString(info.Title), "\n")
|
|
|
|
f:write(GithubizeString(info.Contents), "\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-22 04:18:58 -05:00
|
|
|
--- Collects all permissions mentioned in the info, returns them as a sorted array
|
|
|
|
-- Each array item is {Name = "PermissionName", Info = { PermissionInfo }}
|
|
|
|
local function BuildPermissions(a_PluginInfo)
|
|
|
|
-- Collect all used permissions from Commands, reference the commands that use the permission:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Permissions = a_PluginInfo.Permissions or {}
|
2014-01-22 04:18:58 -05:00
|
|
|
local function CollectPermissions(a_CmdPrefix, a_Commands)
|
|
|
|
for cmd, info in pairs(a_Commands) do
|
2014-10-18 14:51:28 -04:00
|
|
|
CommandString = a_CmdPrefix .. cmd
|
2014-01-22 04:18:58 -05:00
|
|
|
if ((info.Permission ~= nil) and (info.Permission ~= "")) then
|
|
|
|
-- Add the permission to the list of permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Permission = Permissions[info.Permission] or {}
|
|
|
|
Permissions[info.Permission] = Permission
|
2014-01-22 04:18:58 -05:00
|
|
|
-- Add the command to the list of commands using this permission:
|
2014-10-18 14:51:28 -04:00
|
|
|
Permission.CommandsAffected = Permission.CommandsAffected or {}
|
2014-12-04 23:25:46 -05:00
|
|
|
-- First, make sure that we don't already have this command in the list,
|
|
|
|
-- it may have already been present in a_PluginInfo
|
|
|
|
local NewCommand = true
|
|
|
|
for _, existCmd in ipairs(Permission.CommandsAffected) do
|
|
|
|
if CommandString == existCmd then
|
|
|
|
NewCommand = false
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if NewCommand then
|
|
|
|
table.insert(Permission.CommandsAffected, CommandString)
|
|
|
|
end
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Process the command param combinations for permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
local ParamCombinations = info.ParameterCombinations or {}
|
2014-01-22 04:18:58 -05:00
|
|
|
for idx, comb in ipairs(ParamCombinations) do
|
|
|
|
if ((comb.Permission ~= nil) and (comb.Permission ~= "")) then
|
|
|
|
-- Add the permission to the list of permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Permission = Permissions[comb.Permission] or {}
|
|
|
|
Permissions[info.Permission] = Permission
|
2014-01-22 04:18:58 -05:00
|
|
|
-- Add the command to the list of commands using this permission:
|
2014-10-18 14:51:28 -04:00
|
|
|
Permission.CommandsAffected = Permission.CommandsAffected or {}
|
|
|
|
table.insert(Permission.CommandsAffected, {Name = CommandString, Params = comb.Params})
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Process subcommands:
|
|
|
|
if (info.Subcommands ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
CollectPermissions(CommandString .. " ", info.Subcommands)
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
CollectPermissions("", a_PluginInfo.Commands)
|
2014-01-22 04:18:58 -05:00
|
|
|
|
|
|
|
-- Copy the list of permissions to an array:
|
2014-10-18 14:51:28 -04:00
|
|
|
local PermArray = {}
|
2014-01-22 04:18:58 -05:00
|
|
|
for name, perm in pairs(Permissions) do
|
2014-10-18 14:51:28 -04:00
|
|
|
table.insert(PermArray, {Name = name, Info = perm})
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Sort the permissions array:
|
|
|
|
table.sort(PermArray,
|
|
|
|
function(p1, p2)
|
2014-10-18 14:51:28 -04:00
|
|
|
return (p1.Name < p2.Name)
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
)
|
|
|
|
return PermArray
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local function DumpPermissionsForum(a_PluginInfo, f)
|
|
|
|
-- Get the processed sorted array of permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Permissions = BuildPermissions(a_PluginInfo)
|
2014-01-22 04:18:58 -05:00
|
|
|
if ((Permissions == nil) or (#Permissions <= 0)) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Dump the permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[size=X-Large]Permissions[/size]\n[list]\n")
|
2014-01-22 04:18:58 -05:00
|
|
|
for idx, perm in ipairs(Permissions) do
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" - [color=red]", perm.Name, "[/color] - ")
|
|
|
|
f:write(ForumizeString(perm.Info.Description or ""))
|
|
|
|
local CommandsAffected = perm.Info.CommandsAffected or {}
|
2014-01-22 04:18:58 -05:00
|
|
|
if (#CommandsAffected > 0) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[list] Commands affected:\n- ")
|
|
|
|
local Affects = {}
|
2014-01-22 04:18:58 -05:00
|
|
|
for idx2, cmd in ipairs(CommandsAffected) do
|
2014-10-18 14:51:28 -04:00
|
|
|
table.insert(Affects, GetCommandRefForum(cmd))
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(table.concat(Affects, "\n - "))
|
|
|
|
f:write("\n[/list]")
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
if (perm.Info.RecommendedGroups ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n[list] Recommended groups: ", perm.Info.RecommendedGroups, "[/list]")
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n")
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("[/list]")
|
2014-01-22 04:18:58 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
local function DumpPermissionsGithub(a_PluginInfo, f)
|
|
|
|
-- Get the processed sorted array of permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
local Permissions = BuildPermissions(a_PluginInfo)
|
2014-02-05 15:50:35 -05:00
|
|
|
if ((Permissions == nil) or (#Permissions <= 0)) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Dump the permissions:
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("\n# Permissions\n")
|
2014-03-05 13:17:59 -05:00
|
|
|
f:write("| Permissions | Description | Commands | Recommended groups |\n")
|
|
|
|
f:write("| ----------- | ----------- | -------- | ------------------ |\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
for idx, perm in ipairs(Permissions) do
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("| ", perm.Name, " | ")
|
|
|
|
f:write(GithubizeString(perm.Info.Description or ""), " | ")
|
|
|
|
local CommandsAffected = perm.Info.CommandsAffected or {}
|
2014-02-05 15:50:35 -05:00
|
|
|
if (#CommandsAffected > 0) then
|
2014-10-18 14:51:28 -04:00
|
|
|
local Affects = {}
|
2014-02-05 15:50:35 -05:00
|
|
|
for idx2, cmd in ipairs(CommandsAffected) do
|
|
|
|
if (type(cmd) == "string") then
|
2014-10-18 14:51:28 -04:00
|
|
|
table.insert(Affects, GetCommandRefGithub(cmd))
|
2014-02-05 15:50:35 -05:00
|
|
|
else
|
2014-10-18 14:51:28 -04:00
|
|
|
table.insert(Affects, GetCommandRefGithub(cmd.Name, cmd))
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(table.concat(Affects, ", "))
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" | ")
|
2014-02-05 15:50:35 -05:00
|
|
|
if (perm.Info.RecommendedGroups ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(perm.Info.RecommendedGroups)
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(" |\n")
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
--- Dumps the forum-format info for the plugin
|
|
|
|
-- Returns true on success, nil and error message on failure
|
2014-01-03 18:37:57 -05:00
|
|
|
local function DumpPluginInfoForum(a_PluginFolder, a_PluginInfo)
|
|
|
|
-- Open the output file:
|
2014-10-18 14:51:28 -04:00
|
|
|
local f, msg = io.open(a_PluginFolder .. "/forum_info.txt", "w")
|
2014-01-03 18:37:57 -05:00
|
|
|
if (f == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return nil, msg
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Write the description:
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(ForumizeString(a_PluginInfo.Description), "\n")
|
|
|
|
DumpAdditionalInfoForum(a_PluginInfo, f)
|
|
|
|
DumpCommandsForum(a_PluginInfo, f)
|
|
|
|
DumpPermissionsForum(a_PluginInfo, f)
|
2014-03-01 08:29:40 -05:00
|
|
|
if (a_PluginInfo.SourceLocation ~= nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write("[b][color=blue]Source:[/color] [url=", a_PluginInfo.SourceLocation, "]Link[/url][/b]")
|
2014-03-01 08:29:40 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
f:close()
|
|
|
|
return true
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
--- Dumps the README.md file into the plugin's folder with the GitHub Markdown format
|
|
|
|
-- Returns true on success, nil and error message on failure
|
2014-02-05 15:50:35 -05:00
|
|
|
local function DumpPluginInfoGithub(a_PluginFolder, a_PluginInfo)
|
2014-10-18 14:51:28 -04:00
|
|
|
-- Check the params:
|
|
|
|
assert(type(a_PluginFolder) == "string")
|
|
|
|
assert(type(a_PluginInfo) == "table")
|
|
|
|
|
2014-02-05 15:50:35 -05:00
|
|
|
-- Open the output file:
|
2014-10-18 14:51:28 -04:00
|
|
|
local f, msg = io.open(a_PluginFolder .. "/README.md", "w")
|
2014-02-05 15:50:35 -05:00
|
|
|
if (f == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
print("\tCannot dump github info for plugin " .. a_PluginFolder .. ": " .. msg)
|
|
|
|
return nil, msg
|
2014-02-05 15:50:35 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Write the description:
|
2014-10-18 14:51:28 -04:00
|
|
|
f:write(GithubizeString(a_PluginInfo.Description), "\n")
|
|
|
|
DumpAdditionalInfoGithub(a_PluginInfo, f)
|
|
|
|
DumpCommandsGithub(a_PluginInfo, f)
|
|
|
|
DumpPermissionsGithub(a_PluginInfo, f)
|
2014-02-05 15:50:35 -05:00
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
f:close()
|
|
|
|
return true
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
--- Tries to load the g_PluginInfo from the plugin's Info.lua file
|
|
|
|
-- Returns the g_PluginInfo table on success, or nil and error message on failure
|
|
|
|
local function LoadPluginInfo(a_FolderName)
|
|
|
|
-- Load and compile the Info file:
|
2014-10-18 14:51:28 -04:00
|
|
|
local cfg, err = loadfile(a_FolderName .. "/Info.lua")
|
2014-01-03 18:37:57 -05:00
|
|
|
if (cfg == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return nil, "Cannot open 'Info.lua': " .. err
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Execute the loaded file in a sandbox:
|
|
|
|
-- This is Lua-5.1-specific and won't work in Lua 5.2!
|
2014-10-18 14:51:28 -04:00
|
|
|
local Sandbox = {}
|
|
|
|
setfenv(cfg, Sandbox)
|
2014-10-20 14:14:00 -04:00
|
|
|
local isSuccess, errMsg = pcall(cfg)
|
|
|
|
if not(isSuccess) then
|
|
|
|
return nil, "Cannot load Info.lua: " .. (errMsg or "<unknown error>")
|
|
|
|
end
|
|
|
|
|
2014-01-03 18:37:57 -05:00
|
|
|
if (Sandbox.g_PluginInfo == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return nil, "Info.lua doesn't contain the g_PluginInfo declaration"
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
return Sandbox.g_PluginInfo
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
--- Processes the info for one plugin
|
|
|
|
-- Returns true on success, nil and error message on failure
|
2014-01-03 18:37:57 -05:00
|
|
|
local function ProcessPluginFolder(a_FolderName)
|
2014-10-18 14:51:28 -04:00
|
|
|
-- Load the plugin info:
|
|
|
|
local PluginInfo, Msg = LoadPluginInfo(a_FolderName)
|
2014-01-03 18:37:57 -05:00
|
|
|
if (PluginInfo == nil) then
|
2014-10-18 14:51:28 -04:00
|
|
|
return nil, "Cannot load info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Dump the forum format:
|
|
|
|
local isSuccess
|
|
|
|
isSuccess, Msg = DumpPluginInfoForum(a_FolderName, PluginInfo)
|
|
|
|
if not(isSuccess) then
|
|
|
|
return nil, "Cannot dump forum info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
|
|
|
|
-- Dump the GitHub format:
|
|
|
|
isSuccess, Msg = DumpPluginInfoGithub(a_FolderName, PluginInfo)
|
|
|
|
if not(isSuccess) then
|
|
|
|
return nil, "Cannot dump GitHub info for plugin " .. a_FolderName .. ": " .. (Msg or "<unknown error>")
|
|
|
|
end
|
|
|
|
|
|
|
|
-- All OK, return success
|
|
|
|
return true
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-22 06:41:19 -05:00
|
|
|
--- Tries to load LFS through LuaRocks, returns the LFS instance, or nil on error
|
|
|
|
local function LoadLFS()
|
|
|
|
-- Try to load lfs, do not abort if not found ...
|
|
|
|
local lfs, err = pcall(
|
|
|
|
function()
|
|
|
|
return require("lfs")
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
)
|
2014-01-22 06:41:19 -05:00
|
|
|
|
|
|
|
-- ... rather, print a nice message with instructions:
|
|
|
|
if not(lfs) then
|
|
|
|
print([[
|
|
|
|
Cannot load LuaFileSystem
|
|
|
|
Install it through luarocks by executing the following command:
|
|
|
|
luarocks install luafilesystem (Windows)
|
|
|
|
sudo luarocks install luafilesystem (*nix)
|
|
|
|
|
|
|
|
If you don't have luarocks installed, you need to install them using your OS's package manager, usually:
|
|
|
|
sudo apt-get install luarocks (Ubuntu / Debian)
|
|
|
|
On windows, a binary distribution can be downloaded from the LuaRocks homepage, http://luarocks.org/en/Download
|
2014-10-18 14:51:28 -04:00
|
|
|
]])
|
2014-01-22 06:41:19 -05:00
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
print("Original error text: ", err)
|
|
|
|
return nil
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
2014-01-22 06:41:19 -05:00
|
|
|
|
|
|
|
-- We now know that LFS is present, get it normally:
|
2014-10-18 14:51:28 -04:00
|
|
|
return require("lfs")
|
2014-01-03 18:37:57 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-22 06:41:19 -05:00
|
|
|
|
2014-10-18 14:51:28 -04:00
|
|
|
local Arg1 = arg[1]
|
2014-01-22 06:41:19 -05:00
|
|
|
if ((Arg1 ~= nil) and (Arg1 ~= "")) then
|
|
|
|
-- Called with a plugin folder name, export only that one
|
2014-10-18 14:51:28 -04:00
|
|
|
local isSuccess, msg = ProcessPluginFolder(Arg1)
|
|
|
|
if not(isSuccess) then
|
|
|
|
print(msg or "<unknown error>")
|
|
|
|
end
|
2014-01-22 06:41:19 -05:00
|
|
|
else
|
|
|
|
-- Called without any arguments, process all subfolders:
|
2014-10-18 14:51:28 -04:00
|
|
|
local lfs = LoadLFS()
|
2014-01-22 06:41:19 -05:00
|
|
|
if (lfs == nil) then
|
|
|
|
-- LFS not loaded, error has already been printed, just bail out
|
2014-10-18 14:51:28 -04:00
|
|
|
return
|
2014-01-22 06:41:19 -05:00
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
print("Processing plugin subfolders:")
|
2014-01-22 06:41:19 -05:00
|
|
|
for fnam in lfs.dir(".") do
|
|
|
|
if ((fnam ~= ".") and (fnam ~= "..")) then
|
2014-10-18 14:51:28 -04:00
|
|
|
local Attributes = lfs.attributes(fnam)
|
2014-01-22 06:41:19 -05:00
|
|
|
if (Attributes ~= nil) then
|
|
|
|
if (Attributes.mode == "directory") then
|
2014-10-18 14:51:28 -04:00
|
|
|
print(fnam)
|
|
|
|
local isSuccess, msg = ProcessPluginFolder(fnam)
|
|
|
|
if not(isSuccess) then
|
|
|
|
print(" " .. (msg or "<unknown error>"))
|
|
|
|
end
|
2014-01-22 06:41:19 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2014-10-18 14:51:28 -04:00
|
|
|
print("Done.")
|
2014-01-22 06:41:19 -05:00
|
|
|
|
|
|
|
|