From c04e89b2084843256117dfe045393391a7384a74 Mon Sep 17 00:00:00 2001 From: Thijs Schreijer <thijs@thijsschreijer.nl> Date: Sun, 22 Dec 2013 08:25:09 +0100 Subject: adds flag `--verbose` as equivalent for config file `verbose = true` --- src/luarocks/command_line.lua | 6 ++++++ src/luarocks/fs.lua | 5 ++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/luarocks/command_line.lua b/src/luarocks/command_line.lua index 63b918b5..059b7a1c 100644 --- a/src/luarocks/command_line.lua +++ b/src/luarocks/command_line.lua @@ -61,6 +61,12 @@ function run_command(...) local command + if flags["verbose"] then -- setting it in the config file will kick-in earlier in the process + cfg.verbose = true + local fs = require("luarocks.fs") + fs.verbose() + end + if flags["version"] then util.printout(program.." "..cfg.program_version) util.printout(program_description) diff --git a/src/luarocks/fs.lua b/src/luarocks/fs.lua index 2d799da2..b281eb14 100644 --- a/src/luarocks/fs.lua +++ b/src/luarocks/fs.lua @@ -14,7 +14,9 @@ local cfg = require("luarocks.cfg") local pack = table.pack or function(...) return { n = select("#", ...), ... } end local unpack = table.unpack or unpack -if cfg.verbose then -- patch io.popen and os.execute to display commands in verbose mode +local old_popen, old_exec +_M.verbose = function() -- patch io.popen and os.execute to display commands in verbose mode + if old_popen or old_exec then return end old_popen = io.popen io.popen = function(one, two) if two == nil then @@ -36,6 +38,7 @@ if cfg.verbose then -- patch io.popen and os.execute to display commands in verb return unpack(code, 1, code.n) end end +if cfg.verbose then _M.verbose() end local function load_fns(fs_table) for name, fn in pairs(fs_table) do -- cgit v1.2.3-55-g6feb