Skip to content

Commit e12dcc9

Browse files
committed
fix(cli): Suppress trace info in quiet for warnings but do show errors
1 parent b738c1c commit e12dcc9

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

core/sile.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ SILE.lua_isjit = type(jit) == "table"
4747
-- @string full_version
4848
SILE.full_version = string.format("SILE %s (%s)", SILE.version, SILE.lua_isjit and jit.version or _VERSION)
4949

50+
--- Default to verbose mode, can be changed from the CLI or by libraries
51+
--- @boolean quiet
52+
SILE.quiet = false
53+
5054
-- Backport of lots of Lua 5.3 features to Lua 5.[12]
5155
if not SILE.lua_isjit and SILE.lua_version < "5.3" then
5256
require("compat53")

core/utilities/init.lua

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -326,6 +326,7 @@ local _skip_traceback_levels = 2
326326
-- @tparam string message The error message to give.
327327
-- @tparam boolean isbug Whether or not hitting this error is expected to be a code bug (as opposed to misakes in user input).
328328
function utilities.error (message, isbug)
329+
SILE.quiet = false
329330
_skip_traceback_levels = 3
330331
utilities.warn(message, isbug)
331332
_skip_traceback_levels = 2
@@ -350,6 +351,9 @@ end
350351
-- @tparam string message The error message to give.
351352
-- @tparam boolean isbug Whether or not hitting this warning is expected to be a code bug (as opposed to misakes in user input).
352353
function utilities.warn (message, isbug)
354+
if SILE.quiet then
355+
return
356+
end
353357
utilities.msg(message)
354358
if SILE.traceback or isbug then
355359
io.stderr:write(" at:\n" .. SILE.traceStack:locationTrace())

0 commit comments

Comments
 (0)