Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions locale/en-us/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions locale/pt-br/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
2 changes: 2 additions & 0 deletions locale/zh-cn/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
2 changes: 2 additions & 0 deletions locale/zh-tw/script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
24 changes: 21 additions & 3 deletions script/cli/check.lua
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -76,15 +82,27 @@ 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))
.. ' '
.. ('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
Expand Down