diff options
| author | ruki <[email protected]> | 2018-11-04 22:20:13 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-11-04 22:20:13 +0800 |
| commit | d3d05b0c620dbfc318d4c693bc2fb7b556d51d3c (patch) | |
| tree | a91579ba8362498e531c01081d8fe80906da142d /xmake/core/base/utils.lua | |
| parent | 9d22026291016915298cd4cf8b004bef4b6faaec (diff) | |
improve diagnosis info
Diffstat (limited to 'xmake/core/base/utils.lua')
| -rw-r--r-- | xmake/core/base/utils.lua | 45 |
1 files changed, 6 insertions, 39 deletions
diff --git a/xmake/core/base/utils.lua b/xmake/core/base/utils.lua index b3f143ba3..bc1370f3a 100644 --- a/xmake/core/base/utils.lua +++ b/xmake/core/base/utils.lua @@ -133,29 +133,22 @@ function utils.cprintf(format, ...) end end --- the verbose function -function utils.verbose(format, ...) - - -- enable verbose? +-- print the verbose information +function utils.vprint(format, ...) if option.get("verbose") and format ~= nil then utils.print(format, ...) end end --- the verbose error function -function utils.verror(format, ...) - - -- enable verbose? +-- print the verbose information without newline +function utils.vprintf(format, ...) if option.get("verbose") and format ~= nil then - utils.cprint("${bright red}error: ${clear}" .. string.tryformat(format, ...)) - log:flush() + utils.printf(format, ...) end end --- the error function +-- print the error information function utils.error(format, ...) - - -- trace if format ~= nil then utils.cprint("${bright red}error: ${clear}" .. string.tryformat(format, ...)) log:flush() @@ -190,31 +183,5 @@ function utils.ifelse(a, b, c) if a then return b else return c end end --- call functions -function utils.call(funcs, pred, ...) - - -- check - assert(funcs) - - -- call all - for _, func in ipairs(table.wrap(funcs)) do - - -- check - assert(type(func) == "function") - - -- call it - local result = func(...) - - -- exists predicate? - if pred and type(pred) == "function" then - if not pred(name, result) then return false end - -- failed? - elseif not result then return false end - end - - -- ok - return true -end - -- return module return utils |
