From d7662a8916400389fca579772bfdaedadd5e640e Mon Sep 17 00:00:00 2001 From: Opportunity Date: Wed, 15 Jan 2020 14:58:36 +0800 Subject: Improve basic parse --- xmake/core/base/task.lua | 56 +++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 22 deletions(-) (limited to 'xmake/core/base/task.lua') diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index 03b87982d..97c8cec25 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -32,6 +32,37 @@ local sandbox = require("sandbox/sandbox") local config = require("project/config") local sandbox_os = require("sandbox/modules/os") +function task.common_options() + if not task._COMMON_OPTIONS then + task._COMMON_OPTIONS = + { + {'q', "quiet", "k", nil, "Quiet operation." } + , {'y', "yes", "k", nil, "Input yes by default if need user confirm." } + , {nil, "confirm", "kv", nil, "Input the given result if need user confirm.", + " - y|yes", + " - n|no", + " - d|def"} + , {'v', "verbose", "k", nil, "Print lots of verbose information for users." } + , {nil, "root", "k", nil, "Allow to run xmake as root." } + , {'D', "diagnosis", "k", nil, "Print lots of diagnosis information (backtrace, check info ..) only for developers." + , "And we can append -v to get more whole information." + , " e.g. $ xmake -v -D"} + , {nil, "profile", "k", nil, "Print performance data only for developers." } + , {nil, "version", "k", nil, "Print the version number and exit." } + , {'h', "help", "k", nil, "Print this help message and exit." } + , {} + , {'F', "file", "kv", nil, "Read a given xmake.lua file." } + , {'P', "project", "kv", nil, "Change to the given project directory." + , "Search priority:" + , " 1. The Given Command Argument" + , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR" + , " 3. The Current Directory" } + , {category = "action"} + } + end + return task._COMMON_OPTIONS +end + -- the directories of tasks function task._directories() @@ -127,28 +158,9 @@ function task._translate_menu(menu) -- add common options, we need avoid repeat because the main/build task will be inserted twice if not menu._common_options then - table.insert(options, 1, {'q', "quiet", "k", nil, "Quiet operation." }) - table.insert(options, 2, {'y', "yes", "k", nil, "Input yes by default if need user confirm." }) - table.insert(options, 3, {nil, "confirm", "kv", nil, "Input the given result if need user confirm.", - " - y|yes", - " - n|no", - " - d|def"}) - table.insert(options, 4, {'v', "verbose", "k", nil, "Print lots of verbose information for users." }) - table.insert(options, 5, {nil, "root", "k", nil, "Allow to run xmake as root." }) - table.insert(options, 6, {'D', "diagnosis", "k", nil, "Print lots of diagnosis information (backtrace, check info ..) only for developers." - , "And we can append -v to get more whole information." - , " e.g. $ xmake -v -D"}) - table.insert(options, 7, {nil, "profile", "k", nil, "Print performance data only for developers." }) - table.insert(options, 8, {nil, "version", "k", nil, "Print the version number and exit." }) - table.insert(options, 9, {'h', "help", "k", nil, "Print this help message and exit." }) - table.insert(options, 10, {}) - table.insert(options, 11, {'F', "file", "kv", nil, "Read a given xmake.lua file." }) - table.insert(options, 12, {'P', "project", "kv", nil, "Change to the given project directory." - , "Search priority:" - , " 1. The Given Command Argument" - , " 2. The Envirnoment Variable: XMAKE_PROJECT_DIR" - , " 3. The Current Directory" }) - table.insert(options, 13, {category = "action"}) + for i, v in ipairs(task.common_options()) do + table.insert(options, i, v) + end menu._common_options = true end end -- cgit v1.3.1 From 35126b5a38e9833d16c785afe2beab9d87cc3bc2 Mon Sep 17 00:00:00 2001 From: Opportunity Date: Wed, 15 Jan 2020 16:33:12 +0800 Subject: change hint --- xmake/core/base/task.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xmake/core/base/task.lua') diff --git a/xmake/core/base/task.lua b/xmake/core/base/task.lua index 97c8cec25..a3aadb7b0 100644 --- a/xmake/core/base/task.lua +++ b/xmake/core/base/task.lua @@ -46,7 +46,7 @@ function task.common_options() , {nil, "root", "k", nil, "Allow to run xmake as root." } , {'D', "diagnosis", "k", nil, "Print lots of diagnosis information (backtrace, check info ..) only for developers." , "And we can append -v to get more whole information." - , " e.g. $ xmake -v -D"} + , " e.g. $ xmake -vD"} , {nil, "profile", "k", nil, "Print performance data only for developers." } , {nil, "version", "k", nil, "Print the version number and exit." } , {'h', "help", "k", nil, "Print this help message and exit." } -- cgit v1.3.1