Module:Command: Difference between revisions

Don't output rest of command unless ... is the last parameter
That didn't quite do the trick
Line 1: Line 1:
local p = {}
local p = {}
function p.cmd( f )
function p.cmd( f )
local args = f:getParent().args
local args = f
if f == mw.getCurrentFrame() then
args = f:getParent().args
end
local syntax = mw.loadData( 'Module:Command/Syntax' )
local syntax = mw.loadData( 'Module:Command/Syntax' )
local fullCommand
local fullCommand
Line 35: Line 38:
end
end
if fullCommand and syntax[commandName] then
if ( fullCommand or params[1] ) and syntax[commandName] then
local param = 0
local param = 0
function parseParams( defaultParams, sub )
function parseParams( defaultParams, sub )
Line 55: Line 58:
end
end
end
end
if not section[i] then
if not section[i] and ( fullCommand or params[param] == '?' ) then
table.insert( section, v )
table.insert( section, v )
end
end
Line 64: Line 67:
if sub then
if sub then
if not hasValue then
if not hasValue then
section = '(' .. section .. ')'
if fullCommand then
section = '(' .. section .. ')'
else
section = nil
end
end
end