From 3fd4399c6f0c27bc5686e85ee8db7c9bde96ea42 Mon Sep 17 00:00:00 2001 From: Daniel Kolesa Date: Fri, 2 May 2014 13:40:17 +0100 Subject: [PATCH] elua: allow description of positional arguments in help in getopt (using metavar field without short/long) --- src/bin/elua/modules/getopt.lua | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/bin/elua/modules/getopt.lua b/src/bin/elua/modules/getopt.lua index 1b2ebbc672..01327a1352 100644 --- a/src/bin/elua/modules/getopt.lua +++ b/src/bin/elua/modules/getopt.lua @@ -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