diff options
| author | ruki <[email protected]> | 2019-12-20 22:54:20 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2019-12-20 11:26:04 +0800 |
| commit | b8ef2fa1fdf5d7dcd2b8d076f479bbfbad1a0738 (patch) | |
| tree | 11ba3859f3356423249f50a2fde4b4460bd6214e | |
| parent | 4ce400a33c26c4d59e76ccb5dc321fe6dabc60f7 (diff) | |
improve help menu
| -rw-r--r-- | xmake/core/base/option.lua | 31 | ||||
| -rw-r--r-- | xmake/core/base/task.lua | 2 |
2 files changed, 25 insertions, 8 deletions
diff --git a/xmake/core/base/option.lua b/xmake/core/base/option.lua index 6b522818c..dd9df2aa8 100644 --- a/xmake/core/base/option.lua +++ b/xmake/core/base/option.lua @@ -900,7 +900,7 @@ function option.show_menu(task) -- print options if taskmenu.options then - option.show_options(taskmenu.options) + option.show_options(taskmenu.options, task) end end @@ -1024,24 +1024,21 @@ function option.show_main() -- print options if main.options then - option.show_options(main.options) + option.show_options(main.options, "build") end end -- show the options menu -function option.show_options(options) +function option.show_options(options, taskname) -- check assert(options) - -- print header - io.print("") - io.print(colors.translate("${bright}Options: ")) - -- the padding spaces local padding = 42 -- remove repeat empty lines + local is_action = false local emptyline_count = 0 local printed_options = {} for _, opt in ipairs(options) do @@ -1053,11 +1050,31 @@ function option.show_options(options) if emptyline_count < 2 then table.insert(printed_options, opt) end + if opt.category and opt.category == "action" then + is_action = true + end + end + + -- print header + io.print("") + if is_action then + io.print(colors.translate("${bright}Common options: ")) + else + io.print(colors.translate("${bright}Options: ")) end -- print options options = printed_options for _, opt in ipairs(options) do + + -- the following options are belong action? show sub-command section + -- + -- @see core/base/task.lua: translate menu + -- + if opt.category and opt.category == "action" then + io.print("") + io.print(colors.translate("${bright}Sub-command options (" .. taskname .. "): ")) + end -- init the option info local option_info = "" diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index 6d6651986..03b87982d 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -148,7 +148,7 @@ function task._translate_menu(menu) , " 1. The Given Command Argument" , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR" , " 3. The Current Directory" }) - table.insert(options, 13, {}) + table.insert(options, 13, {category = "action"}) menu._common_options = true end end |
