elua: match help categories in a case insensitive way, and add them to lualian

This commit is contained in:
Daniel Kolesa 2014-04-30 10:32:50 +01:00 committed by Daniel Kolesa
parent e293536915
commit a94c216442
2 changed files with 12 additions and 5 deletions

View File

@ -18,15 +18,20 @@ getopt.parse {
usage = "Usage: %prog [OPTIONS] file1.eo file2.eo ... fileN.eo",
args = arg,
descs = {
{ "h", "help", false, help = "Show this message.",
callback = function(d, parser)
getopt.help(parser, io.stdout)
{ category = "General" },
{ "h", "help", nil, help = "Show this message.", metavar = "CATEGORY",
callback = function(d, parser, v)
getopt.help(parser, v, io.stdout)
quit = true
end
},
{ "v", "verbose", false, help = "Be verbose.",
callback = function() printv = print end
},
{ category = "Generator" },
{ "I", "include", true, help = "Include a directory.", metavar = "DIR",
callback = function(d, p, v)
include_dirs[#include_dirs + 1] = v

View File

@ -169,8 +169,10 @@ local help = function(parser, f, category)
lln = math.max(lln, #ln)
lns[#lns + 1] = { ln, desc.help }
elseif desc.category then
iscat = (not category) or (desc.alias == category)
or (desc.category == category)
local lcat = category and category:lower() or nil
local alias = desc.alias and desc.alias:lower() or nil
iscat = (not category) or (alias == lcat)
or (desc.category:lower() == lcat)
if iscat then
wascat = true
lns[#lns + 1] = { false, desc.category }