elua: also use hash fields to store resulting optional arguments

This commit is contained in:
Daniel Kolesa 2014-04-30 11:05:58 +01:00 committed by Daniel Kolesa
parent 8c5cfce2a4
commit ae4daa5401
1 changed files with 6 additions and 2 deletions

View File

@ -48,7 +48,9 @@ local parse_l = function(opts, opt, descs, args, parser)
local rets
if desc.callback then rets = { desc:callback(parser, optval) } end
if not rets or #rets == 0 then rets = { optval } end
opts[#opts + 1] = { desc.alias or desc[1] or desc[2], unpack(rets) }
local optn = desc.alias or desc[1] or desc[2]
opts[#opts + 1] = { optn, unpack(rets) }
opts[optn] = #rets > 1 and rets or rets[1]
return opts, args
end
@ -74,7 +76,9 @@ local parse_s = function(opts, optstr, descs, args, parser)
local rets
if desc.callback then rets = { desc:callback(parser, optval) } end
if not rets or #rets == 0 then rets = { optval } end
opts[#opts + 1] = { desc.alias or desc[1] or desc[2], unpack(rets) }
local optn = desc.alias or desc[1] or desc[2]
opts[#opts + 1] = { optn, unpack(rets) }
opts[optn] = #rets > 1 and rets or rets[1]
end
return opts, args
end