elua: allow description of positional arguments in help in getopt (using metavar field without short/long)

This commit is contained in:
Daniel Kolesa 2014-05-02 13:40:17 +01:00 committed by Daniel Kolesa
parent c427742634
commit 3fd4399c6f
1 changed files with 4 additions and 1 deletions

View File

@ -187,7 +187,8 @@ local help = function(parser, f, category)
local wascat = false
for i, desc in ipairs(parser.descs) do
local nign = desc.help ~= false
if nign and (not category or iscat) and (desc[1] or desc[2]) then
if nign and (not category or iscat)
and (desc[1] or desc[2] or desc.metavar) then
local mv = get_metavar(desc)
local ln = {}
ln[#ln + 1] = " "
@ -201,6 +202,8 @@ local help = function(parser, f, category)
if sdf > 0 then
ln[#ln + 1] = (" "):rep(sdf)
end
elseif not desc[2] and mv then
ln[#ln + 1] = mv
else
ln[#ln + 1] = (" "):rep(lls + 2)
end