From bcca1a559b5b4e0c6d53070e4e6926504f7d5abf Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 23 Mar 2012 13:57:28 -0300 Subject: Improve configuration message in LuaRocks help --- src/luarocks/cfg.lua | 14 ++++++++++---- src/luarocks/help.lua | 14 ++++++++++++-- 2 files changed, 22 insertions(+), 6 deletions(-) diff --git a/src/luarocks/cfg.lua b/src/luarocks/cfg.lua index af1062f8..1147d725 100644 --- a/src/luarocks/cfg.lua +++ b/src/luarocks/cfg.lua @@ -114,8 +114,11 @@ rocks_trees = {} local ok, err = persist.load_into_table(site_config.LUAROCKS_SYSCONFIG or sys_config_file, _M) if ok then sys_config_ok = true -elseif err and ok == nil then - io.stderr:write(err.."\n") +else -- nil or false + sys_config_ok = ok + if err and ok == nil then + io.stderr:write(err.."\n") + end end if not site_config.LUAROCKS_FORCE_CONFIG then @@ -131,8 +134,11 @@ if not site_config.LUAROCKS_FORCE_CONFIG then _M.rocks_servers = nil end util.deep_merge(_M, home_overrides) - elseif err and home_overrides == nil then - io.stderr:write(err.."\n") + else -- nil or false + home_config_ok = home_overrides + if err and home_config_ok == nil then + io.stderr:write(err.."\n") + end end end diff --git a/src/luarocks/help.lua b/src/luarocks/help.lua index 3a366f44..19cd7914 100644 --- a/src/luarocks/help.lua +++ b/src/luarocks/help.lua @@ -24,6 +24,16 @@ local function print_section(section) util.printout("\n"..section) end +local function get_status(status) + if status then + return "ok" + elseif status == false then + return "not found" + else + return "failed" + end +end + --- Driver function for the "help" command. -- @param command string or nil: command to show help for; if not -- given, help summaries for all commands are shown. @@ -68,8 +78,8 @@ function run(...) end print_section("CONFIGURATION") util.printout([[ - Using system configuration file: ]]..sys_file .. " (" .. (sys_ok and "ok" or "failed") ..[[) - and user configuration file: ]]..home_file .. " (" .. (home_ok and "ok" or "failed") ..")\n") + System configuration file: ]]..sys_file .. " (" .. get_status(sys_ok) ..[[) + User configuration file: ]]..home_file .. " (" .. get_status(home_ok) ..")\n") else command = command:gsub("-", "_") if commands[command] then -- cgit v1.2.3-55-g6feb