summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2022-06-09 00:58:54 +0800
committerruki <[email protected]>2022-06-09 00:58:54 +0800
commit19a36ec61750f52b57a5180b4a8ae13a271053fd (patch)
treec0253beab590627d6a2db93a27fd59ff81aa52a2
parent09bd87c9ae1ce98355d1a66302eb372378a1e2ba (diff)
improve help menu
-rw-r--r--xmake/actions/config/xmake.lua5
-rw-r--r--xmake/core/base/option.lua24
2 files changed, 14 insertions, 15 deletions
diff --git a/xmake/actions/config/xmake.lua b/xmake/actions/config/xmake.lua
index 5383bb892..6312e32af 100644
--- a/xmake/actions/config/xmake.lua
+++ b/xmake/actions/config/xmake.lua
@@ -188,7 +188,6 @@ task("config")
{nil, "pkg_searchdirs", "kv", nil , "The search directories of the remote package."
, " e.g."
, " - xmake f --pkg_searchdirs=/dir1" .. path.envsep() .. "/dir2"},
- _project_menu_options,
{category = "Cross Complation Configuration"},
{nil, "cross", "kv", nil, "Set cross toolchains prefix"
, "e.g."
@@ -228,7 +227,9 @@ task("config")
{'o', "buildir", "kv", "build" , "Set build directory."},
{},
{nil, "target", "v" , nil , "Configure for the given target."
- , values = _target_values}}}
+ , values = _target_values},
+ {category = "Project Configuration"},
+ _project_menu_options}}
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua
index 6e3ae0c67..9f058a132 100644
--- a/xmake/core/base/option.lua
+++ b/xmake/core/base/option.lua
@@ -685,8 +685,6 @@ end
-- show the options menu
function option.show_options(options, taskname)
-
- -- check
assert(options)
-- remove repeat empty lines
@@ -694,14 +692,10 @@ function option.show_options(options, taskname)
local emptyline_count = 0
local printed_options = {}
for _, opt in ipairs(options) do
- if not opt[1] and not opt[2] then
- emptyline_count = emptyline_count + 1
- else
- emptyline_count = 0
- end
- if emptyline_count < 2 then
- table.insert(printed_options, opt)
+ if opt.category and printed_options[#printed_options].category then
+ table.remove(printed_options)
end
+ table.insert(printed_options, opt)
if opt.category and opt.category == "action" then
is_action = true
end
@@ -720,19 +714,23 @@ function option.show_options(options, taskname)
end
-- print options
+ local categories = {}
for _, opt in ipairs(printed_options) do
-
if opt.category and opt.category == "action" then
-
-- the following options are belong action? show command section
--
-- @see core/base/task.lua: translate menu
--
table.insert(tablecontent, {})
table.insert(tablecontent, {{"Command options (" .. taskname .. "):", style="${reset bright}"}})
+ elseif opt.category and opt.category ~= "." then
+ local category_root = opt.category:split("/")[1]
+ if not categories[category_root] then
+ table.insert(tablecontent, {})
+ table.insert(tablecontent, {{"Command options (" .. opt.category .. "):", style="${reset bright}"}})
+ categories[category_root] = true
+ end
elseif opt[3] == nil then
-
- -- insert empty line
table.insert(tablecontent, {})
else