From 603ee1c869bd4ffce609451f1d5fc6441ab9c100 Mon Sep 17 00:00:00 2001 From: XeonSquared Date: Wed, 24 May 2017 09:33:42 +0000 Subject: [PATCH] added a --quiet option to build.lua --- build.lua | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/build.lua b/build.lua index 125bdc6..f892c3a 100755 --- a/build.lua +++ b/build.lua @@ -1,9 +1,23 @@ #!/usr/bin/env lua5.2 -- Initialization log = "" +tA = {...} +for k,v in ipairs(tA) do + if type(v) == "string" then + if v:sub(1,10) == "--cfgfile=" then + cfgfile = v:sub(11) + elseif v:sub(1,10) == "--modfile=" then + modfile = v:sub(11) + elseif v == "--quiet" then + quiet = true + end + end +end oldprint=print function print(...) - oldprint(...) + if not quiet then + oldprint(...) + end logline = "" if #{...} > 0 then if #{...} > 1 then @@ -19,16 +33,6 @@ function print(...) end print("Initializing and reading configuration") ts={} -tA = {...} -for k,v in ipairs(tA) do - if type(v) == "string" then - if v:sub(1,10) == "--cfgfile=" then - cfgfile = v:sub(11) - elseif v:sub(1,10) == "--modfile=" then - modfile = v:sub(11) - end - end -end ss="" cfgfile = cfgfile or "build.cfg" modfile = modfile or "modules.cfg" @@ -117,7 +121,11 @@ if cfg.test == "yes" then print("Checking for errors...") err={pcall(load,ss)} if err[1] ~= true then - print(table.unpack(err)) + if quiet then + io.write(table.unpack(err),"\n") + else + print(table.unpack(err)) + end else print("No errors detected by load()") end