From 655ac540d6fba07b0c723fee9693bcbd2bf3b76a Mon Sep 17 00:00:00 2001 From: Paul Emmerich Date: Sat, 20 Apr 2024 17:44:21 +0200 Subject: Output more details while running --check --- script/cli/check.lua | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'script') diff --git a/script/cli/check.lua b/script/cli/check.lua index 5ac9ea13..da55b658 100644 --- a/script/cli/check.lua +++ b/script/cli/check.lua @@ -76,8 +76,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 +87,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 -- cgit v1.2.3 From 577b2eb8c50b6d19c93e3d2937ec45c5ae3ca022 Mon Sep 17 00:00:00 2001 From: Paul Emmerich Date: Sat, 20 Apr 2024 18:03:29 +0200 Subject: --check: Attempt to write output even if an error occurs This enables writing partial output if you press ctrl-c after seeing the first errors show up. --- script/cli/check.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'script') diff --git a/script/cli/check.lua b/script/cli/check.lua index da55b658..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 { -- cgit v1.2.3