From 40aeeb7d3f1f2fdc4b2a18fd6654301f4a757394 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 24 Jun 2015 14:45:05 +0800 Subject: fix bug for show help menu --- xmake/scripts/action/_package.lua | 2 +- xmake/scripts/base/option.lua | 49 +++++++++++++++++++-------------------- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/xmake/scripts/action/_package.lua b/xmake/scripts/action/_package.lua index b6ea690ef..5e91f8e9d 100644 --- a/xmake/scripts/action/_package.lua +++ b/xmake/scripts/action/_package.lua @@ -80,7 +80,7 @@ function _package.menu() , {'h', "help", "k", nil, "Print this help message and exit." } , {} - , {nil, "target", "v", nil, "Package a given target" } + , {nil, "target", "v", "all", "Package a given target" } } } end diff --git a/xmake/scripts/base/option.lua b/xmake/scripts/base/option.lua index 96062b4f8..36963476b 100644 --- a/xmake/scripts/base/option.lua +++ b/xmake/scripts/base/option.lua @@ -653,19 +653,34 @@ function option.print_options(options) print(option_info) -- print more description if exists - for i = 6, #option do + for i = 6, 64 do - -- the description + -- the description, @note some option may be nil local description = option[i] - if description then + if not description then break end - -- is function? get results - if type(description) == "function" then - description = description() + -- is function? get results + if type(description) == "function" then + description = description() + end + + -- the description is string? + if type(description) == "string" then + + -- make spaces + local spaces = "" + for i = 0, padding do + spaces = spaces .. " " end - -- the description is string? - if type(description) == "string" then + -- print this description + print(spaces .. description) + + -- the description is table? + elseif type(description) == "table" then + + -- print all descriptions + for _, v in pairs(description) do -- make spaces local spaces = "" @@ -674,23 +689,7 @@ function option.print_options(options) end -- print this description - print(spaces .. description) - - -- the description is table? - elseif type(description) == "table" then - - -- print all descriptions - for _, v in pairs(description) do - - -- make spaces - local spaces = "" - for i = 0, padding do - spaces = spaces .. " " - end - - -- print this description - print(spaces .. v) - end + print(spaces .. v) end end end -- cgit v1.3.1