diff options
-rw-r--r-- | locale/en-us/script.lua | 2 | ||||
-rw-r--r-- | locale/pt-br/script.lua | 2 | ||||
-rw-r--r-- | locale/zh-cn/script.lua | 2 | ||||
-rw-r--r-- | locale/zh-tw/script.lua | 2 | ||||
-rw-r--r-- | script/cli/check.lua | 24 |
5 files changed, 29 insertions, 3 deletions
diff --git a/locale/en-us/script.lua b/locale/en-us/script.lua index 20d858bb..49751d52 100644 --- a/locale/en-us/script.lua +++ b/locale/en-us/script.lua @@ -646,6 +646,8 @@ CLI_CHECK_INITING = 'Initializing ...' CLI_CHECK_SUCCESS = 'Diagnosis completed, no problems found' +CLI_CHECK_PROGRESS = +'Found {} problems in {} files' CLI_CHECK_RESULTS = 'Diagnosis complete, {} problems found, see {}' CLI_DOC_INITING = diff --git a/locale/pt-br/script.lua b/locale/pt-br/script.lua index 2357aa50..7a114fef 100644 --- a/locale/pt-br/script.lua +++ b/locale/pt-br/script.lua @@ -646,6 +646,8 @@ CLI_CHECK_INITING = 'Inicializando ...' CLI_CHECK_SUCCESS = 'Diagnóstico completo, nenhum problema encontrado' +CLI_CHECK_PROGRESS = -- TODO: need translate! +'Found {} problems in {} files' CLI_CHECK_RESULTS = 'Diagnóstico completo, {} problemas encontrados, veja {}' CLI_DOC_INITING = -- TODO: need translate! diff --git a/locale/zh-cn/script.lua b/locale/zh-cn/script.lua index 6459a104..c16a764f 100644 --- a/locale/zh-cn/script.lua +++ b/locale/zh-cn/script.lua @@ -646,6 +646,8 @@ CLI_CHECK_INITING = '正在初始化...' CLI_CHECK_SUCCESS = '诊断完成,没有发现问题' +CLI_CHECK_PROGRESS = -- TODO: need translate! +'Found {} problems in {} files' CLI_CHECK_RESULTS = '诊断完成,共有 {} 个问题,请查看 {}' CLI_DOC_INITING = diff --git a/locale/zh-tw/script.lua b/locale/zh-tw/script.lua index 43c064b2..1deb9877 100644 --- a/locale/zh-tw/script.lua +++ b/locale/zh-tw/script.lua @@ -646,6 +646,8 @@ CLI_CHECK_INITING = '正在初始化...' CLI_CHECK_SUCCESS = '診斷完成,沒有發現問題' +CLI_CHECK_PROGRESS = -- TODO: need translate! +'Found {} problems in {} files' CLI_CHECK_RESULTS = '診斷完成,共有 {} 個問題,請查看 {}' CLI_DOC_INITING = -- TODO: need translate! diff --git a/script/cli/check.lua b/script/cli/check.lua index 5ac9ea13..3902c4aa 100644 --- a/script/cli/check.lua +++ b/script/cli/check.lua @@ -1,4 +1,4 @@ -local lclient = require 'lclient' +local lclient = require 'lclient'() local furi = require 'file-uri' local ws = require 'workspace' local files = require 'files' @@ -41,8 +41,14 @@ util.enableCloseFunction() local lastClock = os.clock() local results = {} + +local function errorhandler(err) + print(err) + print(debug.traceback()) +end + ---@async -lclient():start(function (client) +xpcall(lclient.start, errorhandler, lclient, function (client) client:registerFakers() client:initialize { @@ -76,8 +82,10 @@ lclient():start(function (client) for i, uri in ipairs(uris) do files.open(uri) diag.doDiagnostic(uri, true) - if os.clock() - lastClock > 0.2 then + -- Print regularly but always print the last entry to ensure that logs written to files don't look incomplete. + if os.clock() - lastClock > 0.2 or i == #uris then lastClock = os.clock() + client:update() local output = '\x0D' .. ('>'):rep(math.ceil(i / max * 20)) .. ('='):rep(20 - math.ceil(i / max * 20)) @@ -85,6 +93,16 @@ lclient():start(function (client) .. ('0'):rep(#tostring(max) - #tostring(i)) .. tostring(i) .. '/' .. tostring(max) io.write(output) + local filesWithErrors = 0 + local errors = 0 + for _, diags in pairs(results) do + filesWithErrors = filesWithErrors + 1 + errors = errors + #diags + end + if errors > 0 then + local errorDetails = ' [' .. lang.script('CLI_CHECK_PROGRESS', errors, filesWithErrors) .. ']' + io.write(errorDetails) + end io.flush() end end |